1 
2 class Base
3 {
4 public:
get_foo()5   virtual int get_foo () { return 1; }
base_function_only()6   int base_function_only () { return 2; }
7 };
8 
9 class Foo : public Base
10 {
11 
12 private:
13   int foo_value;
14 
15 public:
Foo()16   Foo () { foo_value = 0;}
Foo(int i)17   Foo (int i) { foo_value = i;}
~Foo()18   ~Foo () { }
19   void set_foo (int value);
20   int get_foo ();
21 
22   // Something similar to a constructor name.
23   void Foofoo ();
24 
operator ==(const Foo & other)25   bool operator== (const Foo &other) { return foo_value == other.foo_value; }
26 };
27 
set_foo(int value)28 void Foo::set_foo (int value)
29 {
30   foo_value = value;
31 }
32 
get_foo()33 int Foo::get_foo ()
34 {
35   return foo_value;
36 }
37 
Foofoo()38 void Foo::Foofoo ()
39 {
40 }
41 
42 namespace Test_NS {
43 
44 int foo;
45 int bar;
46 
47 namespace Nested {
48 
49 int qux;
50 
51 } /* namespace Nested */
52 
53 } /* namespace Test_NS */
54 
main()55 int main ()
56 {
57   // Anonymous struct with method.
58   struct {
59     int get() { return 5; }
60   } a;
61   Foo foo1;
62   foo1.set_foo (42);		// Set breakpoint here.
63   a.get();			// Prevent compiler from throwing 'a' away.
64   return 0;
65 }
66