/* pointers to objects. the use of -> to access members of objects from a pointer to an object */ #include class Rectangle{ private: double width, length; public: void init(double,double); double area(); }; void Rectangle::init(double x, double y){ width = x; length = y; } double Rectangle::area(){ double area = width * length; cout << "The area of a rectangle with length " << length << " and width " << width << " is " << area << ".\n"; return area; } void main(){ Rectangle r, * r_address; r.init(4,2); r_address = &r; double a = r_address->area(); /* this syntax is nicer than, but equivalent to, the following */ double b = (*r_address).area(); cout << "a is " << a << "; b is " << b << ".\n"; }