Tuesday, 15 July 2014

qt - Passing the parent class pointer to child -


Two sections have been declared below but I get the compilation errors and it looks like loop # included is. Does anyone know the way to fix it?

My purpose is TP that keep the child class in the paternity of the parents so that children can reach the parents' attitudes and qualities.

  #ifndef PARENT_H #define PARENT_H #include "child.h" class guardian {public: child * girl; Parent (); }; #endif // PARENT_H #ifndef CHILD_H # defined CHILD_H # included "parent.h" class child {public: parent * myparent; hair (); }; #endif // CHILD_H    

Unless you only store one pointer in the class , You do not need to provide full range definition in the header, so you can use a forwarded category declaration like this:

  #ifndef PARENT_H #define PARENT_H class Child; Classroom Parents {Public: Child * Girl; Parent (); }; #endif // PARENT_H #ifndef CHILD_H # CHILD_H class guardian defined; Classroom Children {Public: Parents * myparent; hair (); }; #endif // CHILD_H   

You must then include parent.h in parent.c and parent.cpp in parent.c.

No comments:

Post a Comment