mercredi 25 mars 2015

How do I avoid forward declarations?

Let's say I have two classes, A and B:



class B;

class A
{
private:
int an_int;
B *something_else;
public:
A(int n) : an_int(n), something_else(nullptr) {}
};

class B
{
private:
int an_int;
A *something_else;
public:
B(int n) : an_int(n), something_else(nullptr) {}
};


How can I make it so that I don't have to prototype B in order to have a pointer to a B object in class A?


Aucun commentaire:

Enregistrer un commentaire