Please help me find this compile error.
The code is a simplified Composition and Interfaces example from http://en.wikipedia.org/wiki/Composition_over_inheritance
I just posting the first few lines since the compile error is on line 9.
D:\wolf\Documents\teensy\demo_MinGW>g++ polymorph_composition.cpp
polymorph_composition.cpp:9:20: error: expected ')' before '*' token
Object(ADelegate *a, BDelegate *b) : _a(a), _b(b) { };
^
polymorph_composition.cpp:13:3: error: 'ADelegate' does not name a type
ADelegate *_a;
^
polymorph_composition.cpp:14:3: error: 'BDelegate' does not name a type
BDelegate *_b;
^
polymorph_composition.cpp: In member function 'void Object::Afunc()':
polymorph_composition.cpp:10:18: error: '_a' was not declared in this scope
void Afunc() { _a->Afunc(); };
^
polymorph_composition.cpp: In member function 'void Object::Bfunc()':
polymorph_composition.cpp:11:18: error: '_b' was not declared in this scope
void Bfunc() { _b->Bfunc(); };
^
You need to forward declare ADelegate and BDelegate; you are using them before their definitions on lines 17 and 22. You'll also need to move the definitions of Afunc() and Bfunc() below the definitions of ADelegate and BDelegate since they refer to methods.