C++ Concept Map

Function members

Any class member, whether a function member or a data member, may be accessed using the member access operator, the period, which operates on an object of the class type. Consider this class with members DM1 and FM1:

class MA {
public:
  int DM1;
  void FM1();
};

If we have an object of type MA:

  MA object1;
then the members may be accessed (since they have public access control) by:
  object1.DM1
which is an expression whose value is the value of member DM1 inside the object object1, and
  object1.FM1()
which is a call to member function FM1 for object object1. FM1 has direct access to the values inside object1, i.e. the value of DM1.

Class members can also be accessed through pointers, using the -> operator:
  MA *pObject1 = &object1;
  
  pObject1->DM1
  pObject1->FM1()

Please mail any corrections and/or suggestions to Roger Hartley at
rth@cs.nmsu.edu

Copyright © 2003 Roger Hartley