C++ Pocket Reference by Kyle Loudon

C++ Pocket Reference by Kyle Loudon

Author:Kyle Loudon [Kyle Loudon]
Language: eng
Format: epub, mobi
Tags: COMPUTERS / Programming Languages / C++
ISBN: 9781449378943
Publisher: O'Reilly Media
Published: 2009-06-29T16:00:00+00:00


Accessing Members

To access a member of an object, you use the dot form of the selection operator (.). For example, the following assigns 500 to the data member i of an object called object:

object.i = 500;

The following invokes the member function f of object, passing it two arguments, a and b:

object.f(a, b);

To access a member of an object using a pointer to the object, you use the arrow form of selection (->). For example, the following assigns 500 to the data member i of an object referenced by objptr:

objptr->i = 500;

The following invokes the member function f of the object referenced by objptr passing it two arguments, a and b:

objptr->f(a, b);

To access a member from within the class in which it is defined, or from within a derived class (see Inheritance), usually you specify only the name of the member, unless accessing the member through the this pointer. By whatever means you access a member, the compiler either allows or denies access based on the member's access level (see Access Levels for Members).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.