I agree this might be a very beginner's question, but I have no idea why I can't use '.' to access a member of a pointer to an object.
e.g.
JMP *sum_obj = new JMP("0");
JMP a;
sum_obj->number;
a.number;
sum_obj.number; // error: request for member ‘number’ in ‘sum_obj’, which is of pointer type ‘JMP*’ (maybe you meant to use ‘->’ ?)
Here, why should I use ->
for the sum_obj
number
member?
.
and and pointed value accessible by->
). – Barresum_obj
is a pointer.x->y
is the same as(*x).y
. I suggest you read the chapter dealing with pointers in your beginner's C++ text book. – Indigence