I want to overload + for Point+Point and Point+vector
class Vector
{
public:
double x;
double y;
double z;
};
class PointBase
{
public:
double x;
double y;
double z;
PointBase operator+(const Vector &vec) const
{
PointBase b;
b.x=vec.x+this->x;
b.y=vec.y+this->y;
b.z=vec.z+this->z;
return b;
}
};
class Point:public PointBase
{
public:
PointBase operator+(const Point &point) const
{
PointBase b;
b.x=point.x+this->x;
b.y=point.y+this->y;
b.z=point.z+this->z;
return b;
}
Point(PointBase& base)
{
}
Point()
{
}
};
int main()
{
Point p;
Vector v;
p=p+v;
return 0;
}
PointBase operator+(const Point &point) const
hides PointBase operator+(const Vector &vec) const
, why? I expect that 2 overloads work correctly: point+vector
and point +point
.