Sunday, 25 September 2011

THE ARROW OPERATOR



THE ARROW OPERATOR

Member functions can be called with respect to an object through a pointer pointing at the object. The arrow operator does this.

Example:

void main()
{
Distance d1;                // Distance is a class
Distance * dPtr;          // Declaring a pointer of type Distance
dPtr = &d1;
dPtr àsetFeet(1);       //calling member function of Distance Class with à operator
dPtr àsetInches(1.1)  // calling member function of Distance Class with à operator
cout<<dPtràgetFeet() <<endl<< dPtràgetInches(); 
}

No comments:

Post a Comment