c++ 看看题哪里错了,谢谢,

来源:百度知道 编辑:UC知道 时间:2024/05/09 21:59:21
#include <iostream>
using namespace std;
class Point
{public:
Point(float x=0,float y=0);
void setPoint(float,float);
float getX() const ;
float getY() const ;
friend ostream operator <<(ostream & output,const Point &p);
protected:
float x,y;
};

Point::Point(float a, float b)
{
x=a;y=b;
}

void Point::setPoint(float a, float b)
{
x=a;y=b;
}

float Point::getX() const
{
return x;
}

float Point::getY() const
{
return y;
}

ostream & operator <<(ostream & output,const Point &p)
{output<<"["<<p.x<<","<<p.y<<"]"<<endl;
return output;
}

int main()
{
Point p(3.5,6.4);
cout<<p.getX()<<p.getY()<<endl;
p.setPoint(8,6);
cout<<p<<endl

#include <iostream>
#include<windows.h>
using namespace std;
class Point
{public:
Point(float x=0,float y=0);
void setPoint(float,float);
float getX() const ;
float getY() const ;
friend ostream &operator <<(ostream & output,const Point &p);
protected:
float x,y;
};

Point::Point(float a, float b)
{
x=a;
y=b;
}

void Point::setPoint(float a, float b)
{
x=a;
y=b;
}

float Point::getX() const
{
return x;
}

float Point::getY() const
{
return y;
}

ostream & operator <<(ostream & output,const Point &p)
{output<<"["<<p.getX()<<","<<p.getY()<<"]"<<endl;
return output;
}

int main()
{
Point p(3.5,6.4);
cout<<p.getX()<<" "<<p.getY()<