Thanks Sumant!! If I may ask a follow up question, how does the following line work: myT test = (myT)new myT;
It looks like it is casting the type before the 'new' operator?? Any help would be appreciated! nim --- In [email protected], sumant gupta <sumant_r...@...> wrote: > > Hi > Â > Below is the solution: > Â > #include <iostream.h> > typedef struct { > int one; > int *two; > } *myT; > int main() > { > myT test = (myT)new myT; > int y = 20; > test->two = &y; > test->one = 9; > cout<<test->one; > return 0; > } > Â > Regards > Sumant > > --- On Sun, 14/3/10, nimak247 <nimak...@...> wrote: > > > From: nimak247 <nimak...@...> > Subject: [c-prog] How to access members of a typedef struct pointer?? > To: [email protected] > Date: Sunday, 14 March, 2010, 2:13 AM > > > Â > > > > Hello all, > > I am trying to create a type that is a pointer to a struct, but I cant seem > to access the contents of the struct. I am trying to do something like this: > > typedef struct { > int one; > int *two; > } *myT; > > int main() > { > myT *test = new myT; > int y = 20; > test->two = &y; > test->one = 9; > return 0; > } > > I get an error that says "..left of '->two' must point to class/struct/ > union/generic type". I thought by declaring the typedef as a struct that it > would be recognized as such?? > > I am trying to figure this out, but alas, no joy. Can anyone explain where I > am missing it?? > > Any help would be appreciated, > > nim > > > > > > > > > > Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! > http://downloads.yahoo.com/in/internetexplorer/ > > [Non-text portions of this message have been removed] >
