关于vc使用的问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 17:52:32
我写了一个程序
#include<iostream>
using namespace std;
class point
{
public:
point(float a=0,float b=0);
void set(float a,float b);
float getx(){return x;}
float gety(){return y;}
friend ostream& operator<<(ostream&,const point &);
private:
float x,y;
};

point::point(float a,float b)
{
x=a;y=b;
}
void point::set(float a,float b)
{
x=a;y=b;
}
ostream& operator <<(ostream& output,point& po)
{
output<<"the point is \n("<<po.x<<","<<po.y<<")"<<endl;
return output;
}
int main()
{
point p(1.2,3.2);
cout<<p.x<<" "<<p.y<<endl;
cout<<p<<endl;
p.set(8.8,9.99);
cout<<p.x<<" "<<p.y<<endl;
cout<<p<<endl;
return 0;

#include<iostream>
using namespace std;
class point
{
public:
point(float a=0,float b=0);
void set(float a,float b);
float getx(){return x;}
float gety(){return y;}
friend ostream& operator<<(ostream&,const point &);
private:
float x,y;
};

point::point(float a,float b)
{
x=a;y=b;
}
void point::set(float a,float b)
{
x=a;y=b;
}
ostream& operator <<(ostream& output,const point& po)
{
output<<"the point is \n("<<po.x<<","<<po.y<<")"<<endl;
return output;
}
int main()
{
point p(1.2,3.2);
// cout<<p.x<<" "<<p.y<<endl;
cout<<p<<endl;
p.set(8.8,9.99);
// cout<<p.x<<" "<<p.y<<endl;
cout<<p<<endl;
r