Я вложил класс для использования в другом классе и должен попытаться получить доступ к отдельным частям, но не могу. Как мне это сделать?Доступ к переменным во вложенных классах
class Point
{
public:
Point() { float x = 0, y = 0; }
void Input(int &count); //input values
Rectangle myRec;
private:
float x, y;
};
class Rectangle
{
public:
Rectangle(); //side1 - horizontal, side2 - vertical
void SetPoint(const Point point1, const Point point2, const Point point3, const Point point4) { LLPoint = point1; LRPoint = point2; URPoint = point3; ULPoint = point4; }
float CalcSides(Point LL, Point LR, Point UL, Point UR);
private:
Point LLPoint, LRPoint, ULPoint, URPoint;
float side1, side2, length, width, area, perimeter; //side1 - horizontal, side2 - vertical
};
float Rectangle::CalcSides(Point LL, Point LR, Point UL, Point UR)
{
side1 = (LR.x - LL.x);
}
Как получить доступ к значениям x и y для точек, которые я создал в классе Rectangle?
Я забыл упомянуть, что у меня проблемы с функцией Rectangle :: CalcSides. Он продолжает говорить мне, что значения х недоступны. – Hawkrocker