Computer Science Canada

having a class as a member of one structure...

Author:  Homer_simpson [ Tue Jul 08, 2003 11:04 pm ]
Post subject:  having a class as a member of one structure...

let's say i have created some class and named it MyClass;
and now i'm creating a structure like this

code:
typedef struct _MONEY {     
double x,y,z;
MyClass Class_1;                               
} MONEY;


Is that possible?

Author:  UBC_Wiskatos [ Tue Jul 08, 2003 11:15 pm ]
Post subject:  Re: having a class as a member of one structure...

Homer_simpson wrote:
let's say i have created some class and named it MyClass;
and now i'm creating a structure like this

code:
typedef struct _MONEY {     
double x,y,z;
MyClass Class_1;                               
} MONEY;


Is that possible?


Most definitely yes, just be sure to include the header of the other class, if you follow that organization style.

Author:  Homer_simpson [ Wed Jul 09, 2003 12:07 am ]
Post subject: 

hmmm... then there must be something wrong with my coding... since the structure wont take it as a member Confused

Author:  rizzix [ Wed Jul 09, 2003 2:57 am ]
Post subject: 

try MyClass *myclassobj;
yea use a pointer of type MyClass

Author:  Homer_simpson [ Wed Jul 09, 2003 1:28 pm ]
Post subject: 

nah... didn't need pointer i got it working now...


: