Friend function in C++ – You have to implement the concept of Friend function in C++…


You have to implement the concept of Friend function in C++. The final task is to create two classes Point and Distance. You have been provided with N points, each having (x,y)coordinates.

Class Point contains two integer data fields x and y denoting (x,y) coordinates of a point and a friend function MaxDistance().

Class Distance contains a function Find_Distance() which takes four integer parameters x1, x2, y1 and y2 and returns the distance between (x1,y1) and (x2,y2). Return the maximum distance between any two points from N points.

You’ve been provided with a starter code which contains sub-tasks as defined below:

Subtask 1 : Create a class Point containing two data fields x and y , a constructor Point() and a friend function MaxDistance() .

Subtask 2 : Create a class Distance which contains a function Find_Distance() to find the distance between any two points and a friend function MaxDistance() .

Subtask 3 : Create a friend function MaxDistance() which takes a vector of Points and an object of distance to call Find_Distance() function .

Related Posts

Close Bitnami banner
Bitnami