In addition to the main program and the class, I am supposed to write three nonmember functions.
1.A function to determine if three points form a triangle. The function should return a 1 if they form a triangle and return a 0 otherwise. In order to form a triangle. No two points can be equal.Find the distance between each pair of points. If the largest of the three distances equals the sum of the other two distances, then the points are on a line.
2. A function to find the perimeter of a triangle formed by three points (if they are not in a line).
3. A function to find the area of the triangle formed by three points (if they are not in a line) using the following formula, where a, b, and c are the lengths of the three sides and s is the perimeter of the triangle.
I feel lost on this question. I was guessing to use a friend function but I don't know how to connect everything. I don't necessarily need an answer, but some pointers would help. Here is my program so far:
//Jessica Ewing
//Homework Classes
# include <iostream>
# include <iomanip>
# include <cmath>
using namespace std;
class Point
{
private:
double x, y, z;
public:
void prompt_user();
void display();
double dis(Point);
double equal(Point);
};
Unless you give your Point class some functions to access their internal coordinates you will have to use friend functions. These must be declared in your point class:
Actually, since you only ever need to check distances and whether two points are equal, you don't need friend functions since you have methods to do that.