I have two classes using each other.
Basically, I have an helper class and an head class (I'll call it like that, head uses helper, but helper access members from head).
So it looks like that :
class CHead;
class CHelper
{
public:
Chelper() : m_head(0) {}; // default constructor
CHelper(CHead *head) : m_head(head) {};
SomeFunction(int id, int type = m_head->m_vTypes[id]); // ERROR HERE
private:
CHead *m_head;
[...]
bla bla
};
class CHead {
friend class CHelper; // CHelper can access CHead members
public:
CHead(bla bla) : bla bla { bla bla };
// Member m_helper is constructed at constructor end with smtn
// like m_helper = CHelper(this);
private:
CHelper m_helper;
[...]
bla bla
}
Well, I am getting two errors I don't understand :
First, when trying to do m_head->m_vTypes[] I get :
A non static member reference must be relative to a specific object
Second, I get
identifier "id" is undefined
I don't get these errors. The first should pass without a problem no? Since I declared CHelper a friend of CHead. The second makes me angry. "id" is declared right before as first argument...
Anyone can help?