Question
I have all this code, except the only part I can't get to compile is the perimeter = A.distance(B) + B.distance(C) + C.distance(A); gives me
I have all this code, except the only part I can't get to compile is the perimeter = A.distance(B) + B.distance(C) + C.distance(A);
gives me the error "class point doesn't have member distance"
#include
class Point { private: int x; int y;
public: Point() { x = 0; y = 0; }
Point(int x, int y) { this->x = x; this->y = y; }
int getX() { return x; }
int getY() { return y; }
void setX(int x) { this->x = x; }
void setY(int y) { this->y = y; } };
class Triangle { private: Point A; Point B; Point C; Point distance; double area; double perimeter;
public: Triangle(Point A, Point B, Point C) { this->A = A; this->B = B; this->C = C; area = 0.5 * abs((B.getX() - A.getX()) * (C.getY() - A.getY()) - (C.getX() - A.getX()) * (B.getY() - A.getY())); perimeter = A.distance(B) + B.distance(C) + C.distance(A); }
double getArea() { return area; }
double getPerimeter() { return perimeter; } };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started