LOGBOOK

HELP

Quiz Entry - updated: 2026.07.06

What's the difference between . and -> in C++?

. accesses a member of an object; -> accesses a member through a pointer to an object.

Vehicle v(4);
v.show();        // object: use the dot

Vehicle *p = &v;
p->show();       // pointer: use the arrow
(*p).show();     // equivalent: dereference, then dot

Rule of thumb:

  • object.member
  • pointer->member

a->b is just shorthand for (*a).b. This is exactly the same rule C uses for structs — C++ simply extends it to classes (members include methods, not just fields).

Go deeper:

From Quiz: REVE1 / C++ Programming | Updated: Jul 06, 2026