| application-operator-overload/vers1/prog.cc - Sample uses of the application operators - Funny and artificial. | Lecture 6 - slide 21 : 40 Program 3 |
// Sample uses of the Point function call operators.
#include <iostream>
#include <string>
#include "point.h"
int main(){
using namespace std;
Point p{1,2},
q{3,4};
double d, e;
d = p(5); // Use the application operator on p, pass 5 as the int parameter.
// Pretends that p is a function.
// 1 + 2 + 2*5
cout << "d: " << d << endl; // 13
e = p(q); // Another overload of the application operator.
// Applies p on q
// Pretends, in a similar way, that p is a function.
// 1*3 + 2*4
cout << "e: " << e << endl; // 11
}