The task is to create a trapezoid class with coordinates of points in the form of "x" and "y". Created a class "Point" which has 2 variables x and y. When accessing them, the error "member Trapezoid :: A unavailable" occurs.
class Point { public: int x, y; }; class Trapezoid { Point A = Point(); Point B = Point(); Point C = Point(); Point D = Point(); Point H = Point(); double GetAB() { return sqrt(pow(Bx - Ax, 2) + pow(By - Ay, 2)); } double GetBC() { return sqrt(pow(Cx - Bx, 2) + pow(Cy - By, 2)); } double GetCD() { return sqrt(pow(Dx - Cx, 2) + pow(Dy - Cy, 2)); } double GetDA() { return sqrt(pow(Ax - Dx, 2) + pow(Ay - Dy, 2)); } double Area() { return GetAB() * GetBC(); } double Perimetr() { return (GetAB() + GetBC()) * 2; } }; int main() { Trapezoid trapezoid = Trapezoid(); trapezoid.Ax = 1; }
Point A = Point();
and we are definitely writing C ++ and not Java?) In general, just writePoint A
- pavel