M
Manuel
Hi,
I've read that a line like this:
square *s1 = new square(0,0,20,20);
- alloc the memory needed for obj square,
- create a new object ,
- and return the address into the pointer s1
so, if I use the dereference operator, I access the obj.
The square obj has a method called "setBackgroundColor", so I thinked
to use simply:
*s2.setBackgroundColor(0.0,0.0,0.8,0.5);
but this not work:
- request for member of non-aggregate type before '(' token
Instead, if I use:
(*s2).setBackgroundColor(0.0,0.0,0.8,0.5);
it work.
I think that the first don't work because the compiler consider
*s2.setBackgroundColor(0.0,0.0,0.8,0.5);
as
*(s2.setBackgroundColor(0.0,0.0,0.8,0.5));
but it's only a my idea, so I'm looking for a "real" explanation
thx,
Manuel
I've read that a line like this:
square *s1 = new square(0,0,20,20);
- alloc the memory needed for obj square,
- create a new object ,
- and return the address into the pointer s1
so, if I use the dereference operator, I access the obj.
The square obj has a method called "setBackgroundColor", so I thinked
to use simply:
*s2.setBackgroundColor(0.0,0.0,0.8,0.5);
but this not work:
- request for member of non-aggregate type before '(' token
Instead, if I use:
(*s2).setBackgroundColor(0.0,0.0,0.8,0.5);
it work.
I think that the first don't work because the compiler consider
*s2.setBackgroundColor(0.0,0.0,0.8,0.5);
as
*(s2.setBackgroundColor(0.0,0.0,0.8,0.5));
but it's only a my idea, so I'm looking for a "real" explanation
thx,
Manuel