Click to See Complete Forum and Search --> : C++ class


Tapan
May 9th, 1999, 10:39 PM
I have a problem with classes of c++;
eg.

typedef struct tag{
char *ppp;
}X;

class Y
{
X *exx;
char *yyy;
};

i want to access members of X through Y
eg. Y *yyy;
now i want to access ppp , how do i access it?or how do i make a pointer to X?
Fast reply appreciated
Tapan

May 10th, 1999, 01:27 AM
First of all, you must create an instance of class Y
Y *yyy = new Y;
Now, you must connect member pointer 'exx' to real object of type X, i.e.
yyy->exx = new X;
And now, you must connect member pointer 'ppp' to real data
yyy->exx->ppp = new char[16];
strcpy(yyy->exx->ppp, "BlahBlahBlah");
Hope this helps. If not, or you have any questions, write me to iliani@hotmail.com
(Sorry for my bad english)