1 #include <stdio.h>
2
3 namespace Foo
4 {
5 namespace Bar
6 {
7 class Baz
8 {
9 public:
Baz(int value)10 Baz (int value):m_value(value) {}
Function()11 int Function ()
12 {
13 printf ("%s returning: %d.\n", __FUNCTION__, m_value);
14 return m_value;
15 }
16 private:
17 int m_value;
18 };
19
20 class Baz2
21 {
22 public:
Baz2(int value)23 Baz2 (int value):m_value(value) {}
Function()24 int Function ()
25 {
26 printf ("%s returning: %d.\n", __FUNCTION__, m_value);
27 return m_value;
28 }
29 private:
30 int m_value;
31 };
32
33 static int bar_value = 20;
Function()34 int Function ()
35 {
36 printf ("%s returning: %d.\n", __FUNCTION__, bar_value);
37 return bar_value;
38 }
39 }
40 }
41
42 class Baz
43 {
44 public:
Baz(int value)45 Baz (int value):m_value(value) {}
Function()46 int Function ()
47 {
48 printf ("%s returning: %d.\n", __FUNCTION__, m_value);
49 return m_value;
50 }
51 private:
52 int m_value;
53 };
54
55 int
Function()56 Function ()
57 {
58 printf ("I am a global function, I return 333.\n");
59 return 333;
60 }
61
main()62 int main ()
63 {
64 Foo::Bar::Baz mine(200);
65 Foo::Bar::Baz2 mine2(300);
66 ::Baz bare_baz (500);
67
68 printf ("Yup, got %d from Baz.\n", mine.Function());
69 printf ("Yup, got %d from Baz.\n", mine2.Function());
70 printf ("Yup, got %d from Baz.\n", bare_baz.Function());
71 printf ("And got %d from Bar.\n", Foo::Bar::Function());
72 printf ("And got %d from ::.\n", ::Function());
73
74 return 0;
75
76 }
77