As the following four files, the codes will not compile due to header circular reference.
Here is my dilemma. A is a parent with multiple kids B, so A contains B. B sometimes need to retrieve some parameters from A, which I used a pointer inside B. This approach is very common for me to use in C#, but I just cannot figure out how to do it in C++, as A need to have B.h to know B, and B will will need A.h to have pointer A. Is there a syntax to handle it?
Thanks
A.h
#include <vector>
#include "B.h"
using namespace std;
class A
{
public:
A(void);
~A(void);
vector<B> childList;
};
A.cpp
#include "StdAfx.h"
#include "A.h"
A::A(void)
{
}
A::~A(void)
{
}
B.h
#include "A.h"
class B
{
public:
B(void);
~B(void);
A* parent;
};