I have a rectangle class with a friend point class. I am using cartesian coordinates, so I will have four points in the rectangle class. The points are defined in the point class. When defining the rectangle constructor in the source file, I get the error(marked in comment):
Rectangle has no member Rectangle
header:
using namespace std;
class Rectangle
{
public:
Rectangle(Point, Point, Point, Point);
friend class Point;
~Rectangle();
private:
Point a;
Point b;
Point c;
Point d;
};
class Point
{
public:
Point(int, int);
private:
int x;
int y;
};
source:
Rectangle::Rectangle(Point v1, Point v2, Point v3, Point v4) //error here
{
}
Point::Point(int value1, int value2)
{
if (x <= 20 && y <= 20){
x = value1;
y = value2;
}
else{
throw invalid_argument("");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…