Consider an Account
class that has a public setBalance
member function. Given the following declarations:
Account account; // an Account object
// accountRef refers to an Account object
Account &accountRef = account;
// accountPtr points to an Account object
Account *accountPtr = &account;
You can invoke member function setBalance
using the dot (.
) and arrow (->
) member selection operators as follows:
// call setBalance via the Account object
account.setBalance( 123.45 );
// call setBalance via a reference to the Account object
accountRef.setBalance( 123.45 );
// call setBalance via a pointer to the Account object
accountPtr->setBalance( 123.45 );
18.222.155.187