+ 1
Operator Overloading<<
https://code.sololearn.com/ca23a1a23A25 how can I fix this error?
3 Respuestas
+ 1
#include <iostream>
using namespace std;
class Point
{
friend ostream& operator<<(ostream&,const Point&);
private:
float x,y,z;
public:
Point(float x1=0, float y1=0, float z1=0)
{
x=x1;
y=y1;
z=z1;
}
};
ostream& operator<<(ostream& ostr,const Point& point)
{
return ostr<< "(" << point.x<< "," << point.y << "," << point.z << ")";
}
int main()
{
Point p1(1,-20,3);
cout<<p1;
}
+ 1
You just need to use point.x , point.y, point.z
0
Yes thank you @Yugraj I've corrected it