[求助]看看这个程序,为什么有错误
我是在VC++6.0上运行的,结果发现3处错误,2处警告,实在没想明白,请高手指教.#include <iostream>
using namespace std;
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,y;
};
void point::setpoint(float a,float b)
{
x=a;y=b;
}
point::point(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 p1(3.5,4.6);
cout<<"x="<<p1.getX()<<",y="<<p1.getY()<<endl;
p1.setpoint(8.5,6.8);
cout<<"p(new):"<<p1<<endl;
return 0;
}