previous | index | next

Classes and Pointers

If you have a pointer to a variable of class type, you can use the dereferencing operator "->":
  ItemInfo* item;
  ...
  double total = item->price;
  cout << "Color: " << item->getColor();
Accessing an instance variable of a class object is very much like accessing a variable member of a struct.

Calling a method on a class object is also described as passing a message to the object.


previous | index | next