Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class TwoDim
- {
- public:
- TwoDim(int x, int y)
- {
- px=new int;
- py=new int;
- *px=x;
- *py=y;
- }
- void set(int x, int y)
- {
- *px=x;
- *py=y;
- }
- private:
- int *px, *py;
- friend ostream& operator<<(ostream& o, const TwoDim t);
- };
- ostream& operator<<(ostream& o, const TwoDim t)
- {
- *t.px=1;
- *t.py=2;
- o << *t.px << " " << *t.py;
- return o;
- }
- int main()
- {
- TwoDim x(1,2), y(10,20);
- cout<<x;
- x=y;
- x.set(100,200);
- y.set(1000,2000);
- cout<<x<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement