16-Friends - #include <iostream> using namespace std;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
using namespace std; // friends // it is good to have friends, especially good ones // a friend can exist as either a function or an entire // class that exists outside of the class scope of one // class but has access rights to the private members of // that class class Point { // friend declaration. Establishes the friendship // between the Point class and setCoordinates // function that is defined outside of the Point // class scope friend void setCoordinates(Point &ob, float x1, float y1); friend void setCoordinates(); friend void aSetCoordinates(Point ob, float x1, float y1); friend void pSetCoordinates(Point *ob, float x1, float y1); private: float x, y; public: float getX() const { return x; } float getY() const { return y; } void print() const { cout << "(" << x << ", " << y << ")" << endl; } }; { ob.x = x1; ob.y = y1; //this->// has no context here } //void setCoordinates(Point ob, float test) //{ // ob.x = test;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

16-Friends - #include &lt;iostream&gt; using namespace std;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online