A
al pacino
i want to create classes such that their objects point to each other
,class A holds the pointer
to class B and vice versa such as:
class B//forward declaration
class A
{
public:
A(){......................}
................
funa(B *){................................}
private:
B *bptr; //initially 0,can be pointed to any object of B using the
member function
...........
};
//actual defination of class B
class B
{
public:
B(){.............................}
funa(A *){.............................}
private:
A *aptr;
};
is the above approach correct, what could be a better way to achieve
this.
thanks
,class A holds the pointer
to class B and vice versa such as:
class B//forward declaration
class A
{
public:
A(){......................}
................
funa(B *){................................}
private:
B *bptr; //initially 0,can be pointed to any object of B using the
member function
...........
};
//actual defination of class B
class B
{
public:
B(){.............................}
funa(A *){.............................}
private:
A *aptr;
};
is the above approach correct, what could be a better way to achieve
this.
thanks