Hey guys I’m having trouble setting up a header file the way I need it to be. To simplify my question here’s an example:
#ifndef MYHEADER_H
#define MYHEADER_H
class Parent
{
Child mykid; //a kid of mine
void dosomething(void);
};
class Child
{
Parent * mydad; //pointer back to my dad
void dosomething(void);
};
#endif // MYHEADER_H
I’m basicly needing to use one class inside of another class before the compiler even knows about it. Is there a way to tell the compiler about my classes before I define there insides?
This:
Suggestion: move them in separate headers, forward-declare
ParentinChild.hand#include "Child.h"inParent.h.Parentneeds a full definition ofChildto work,Childonly needs a declaration.I also suggest you stop using raw pointers.