#include <iostream>
using namespace std;
class Distance; // forward declaration
class Point {
private:
int x;
public:
Point(int v) : x(v) {}
friend int sumValues(const Point&, const Distance&);
// your code here: declare friend function sumValues
};
class Distance {
private:
int d;
public:
Distance(int v) : d(v) {}
friend int sumValues(const Point&, const Distance&);
// your code here: declare friend function sumValues
};
int sumValues(const Point& p, const Distance& d1)
{
cout << "Sum=" << p.x + d1.d << endl;
return 0;
}
// your code here: define friend function sumValues
int main() {
int a, b;
cin >> a >> b;
Point p(a);
Distance dist(b);
sumValues(p, dist);
return 0;
}
Input
5 7
Expected Output
Sum=12