大家帮忙看一下到底什么问题?
#include<iostream>
class point
{
public:
point(float,float);
void setpoint(float,float);
float getX() const {return x;}
float getY() const {return y;}
friend ostream &operator<<(ostream &,const point &);
protected:
float x;
float y;
};
point::point(float a,float b)
{
x=a;
y=b;
}
void point::setpoint(float a,float b)
{
x=a;
y=b;
}
ostream &operator<<(ostream &output,const point &p)
{
output<<"["<<p.x<<","<<p.y<<"]"<<endl;
return output;
}
int main()
{
point p(3.5,6.4);
cout<<"x="<<p.getX()<<",y="<<p.getY()<<endl;
p.setpoint(8.5,6.8);
cout<<"p(new):"<<p<<endl;
}