Calling method on an object that is a private member of a class

a.myVector().head() will not work because myVector is private to the outside world, only code inside of ListofArrays (or friends of ListofArrays) can access it.

a.head() will work only if ListofArrays exposes its own public head() method, eg:

class ListofArrays
    vector myVector;

    Type head();

Type ListofArrays::head()
    return myVector.head();

Leave a Comment