Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_NameSpaces / src / cpp / core / namespace / 01_procedures / useNameSapceProcedures.cpp
1 #include <iostream>
2
3 using std::cout;
4 using std::endl;
5
6 /*----------------------------------------------------------------------*\
7 |* Declaration *|
8 \*---------------------------------------------------------------------*/
9
10 /*--------------------------------------*\
11 |* Public *|
12 \*-------------------------------------*/
13
14 void useNameSpaceProcedure();
15
16 /*--------------------------------------*\
17 |* Private *|
18 \*-------------------------------------*/
19
20 namespace v1
21 {
22 static int V = 1;
23
24 static float value();
25 }
26
27 namespace v2
28 {
29 static int V = 2;
30
31 static float value();
32 }
33
34 /*----------------------------------------------------------------------*\
35 |* Implementation *|
36 \*---------------------------------------------------------------------*/
37
38 /*--------------------------------------*\
39 |* Public *|
40 \*-------------------------------------*/
41
42 void useNameSpaceProcedure()
43 {
44 cout << endl<<"[Using Namespaces with procedures] :" << endl<<endl;
45 float v1 = v1::value();
46 float v2 = v2::value();
47
48 cout << "value of v1 = " << v1 << " V = " << v1::V << endl;
49 cout << "value of v2 = " << v2 << " V = " << v2::V << endl;
50 }
51
52 /*--------------------------------------*\
53 |* Private *|
54 \*-------------------------------------*/
55
56 /**
57 * v1 est le name space
58 */
59 float v1::value()
60 {
61 return 1.0f;
62 }
63
64 /**
65 * v2 est le name space
66 */
67 float v2::value()
68 {
69 return 2.0f;
70 }
71
72 /*----------------------------------------------------------------------*\
73 |* End *|
74 \*---------------------------------------------------------------------*/
75