can someone tell me what is the different between (*ptr).field and ptr->field?
I know it connect somehow to static and dynamic linking, but i dont know what is it.
can someone tell me the differnet and give me an example?
edit:
if i have this code:
Point p; //point is a class that derive from class shape
Shape *s=&p;
//there is a diffrence if i write:
(*s).print(); //print is virtual func
s->print(); // the answers will not be the same, why?
TNX!
it has nothing to do with static or dynamic linking
both expressions will return the value of ptr.field
the ptr->field form is an abbreviated syntax for accessing a member directly from a pointer
UPDATE: it occurred to me that your original intent was not linking but binding
if this indeed was what you were aiming to then there is static binding and dynamic binding
which have some relation to the -> operator see here