#include <iostream>
using namespace std;

class Distance;  // forward declaration

class Point {
 private:
 int x;

 public:
  Point(int v) : x(v) {}
  	// your code here: declare friend function sumValues
	friend int sumValues(const Point&,const Distance&);
};

class Distance {
 private:
 	int d;

 public:
 	Distance(int v) : d(v) {}
 	// your code here: declare friend function sumValues
	friend int sumValues(const Point&,const Distance&);
};

// your code here: define friend function sumValues
int sumValues(const Point &p,const Distance &dist)
{
	return p.x+dist.d;
}

int main() {
	int a, b;
	cin >> a >> b;
	
	Point p(a);
	Distance dist(b);

	cout<<"Sum="<<sumValues(p, dist)<<endl;;
	return 0;
}
Upvote
Downvote
Loading...

Input

5 7

Expected Output

Sum=12