How can I properly reference child and parent objects within both objects (doubly-linked child and parent)? When doing that, I get a compilation error: **** does not name a type
. I suspect it has to do with the #include statements being omitted due to the #define tags. How should these tags be hence included?
The three files (Parent.h, Child.h, main.cpp) written as such:
/* Parent.h */
#pragma once
#ifndef _CHILD_CLS
#define _CHILD_CLS
#include "Child.h"
class Parent {
public:
Parent() {}
~Parent() {}
void do_parent(Child* arg);
};
#endif
/* Child.h */
#pragma once
#ifndef _CHILD_CLS
#define _CHILD_CLS
#include "Parent.h"
class Child {
public:
Child() {}
~Child() {}
void do_child(Parent* arg);
};
#endif
/* main.cpp */
#include "child.h"
#include "parent.h"
int main()
{
Child a();
Parent b();
a.do_parent(Child& arg);
return 0;
}