Sunday, 15 September 2013

c++ - Forward declaration of class / Invalid use of incomplete type -



c++ - Forward declaration of class / Invalid use of incomplete type -

i have 6 classes, isn't actual code, simple version

basea:

class basea { public: basea(); virtual ~basea(); void update() { // body functions in seperate file (auto iter : list_of_bs) { iter->update(); } } private: vector<baseb*>* list_of_bs; };

baseb:

class baseb { public: baseb(); virtual ~baseb(); void update() { // body functions in seperate file (auto iter : list_of_cs) { iter->update(); } } private: vector<basec*>* list_of_cs; };

basec

class basec { public: basec(); virtual ~basec(); void update() { // body functions in seperate file // whatever } };

then have 3 other classes, a, b, , c inherit each of respective base of operations classes. add together instance of b or c list_of_bs/list_of_cs can have own code run when update function called.

the problem is, comes errors "forward declaration of class / invalid utilize of incomplete type" in various files. how can set scheme doesn't have these errors?

if want see actual code, can find here: https://github.com/ja-ake/openworld

read readme.

the error getting result of using forwards declaration , trying phone call method or access fellow member without providing total declaration.

the prepare create sure #include .h file containing total class definition (not cc file contains method definitions) before calling method on class.

c++ inheritance compiler-errors

No comments:

Post a Comment