![]() ![]() ![]() | The program that use the operator. | Lecture 3 - slide 33 : 36 Program 3 |
#include <iostream> #include "point.h" using namespace std; // Friend of Point. Returns moved copy of p. Point Move(const Point &p, double dx, double dy){ return Point(p.x + dx, p.y + dy); } int main(){ Point p(1,2), q(3,4), r; Point(3).move(1,2); // Moving temporary Point - not useful. //3.move(1,2); // Point(3).move(1.2) is not attempted. // No implicit conversion on leftmost operand of . r = Move(3, 1,2); // Implicit conversion of 3.0 to the point (3,3). // Moving this point to (4,5). cout << "Point p: " << p << endl; // (1,2) cout << "Point q: " << q << endl; // (3,4) cout << "Point r: " << r << endl; // (4,5) }