2011
12.22

One can access C++ data members and functions using the dot (.) operator for locally created objects. To access objects on the free store, one must dereference the pointer and call the dot operator on the object pointed to by the pointer. One could access the doSomething member function as follows:

(*pObject).doSomething();

Parentheses are used to assure that pObject is deferenced before doSomething is accessed.

Because this is cumbersome, C++ provides a shorthand operator for indirect access: the points-to operator (->), which is created by typing the dash (-) immediately followed by the greater-than symbol (>). C++ treats this as a single symbol. Using the points-to notation, one could access the doSomething member function as follows:

pObject->doSomething();

reference:

http://www.cplusplus.com/doc/tutorial/structures/

No Comment.

Add Your Comment