two or more data types in declaration of'getpoint2D'//C++

[复制链接]
查看11 | 回复2 | 2010-8-29 12:42:36 | 显示全部楼层 |阅读模式
下面则是出问题的相应类的声明,大家看看哪里有问题
class point2D//The point in the plane
{
public:
point2D (double x=0,double y=0);
void getpoint2D(double,double);
double getx() const {return x;}
double gety() const {return y;}
friend ostream &operator<<(ostream &,const point2D &);
protected:
double x,y;
}
void point2D::getpoint2D(double a,double b)
{
x=a;y=b;
}
ostream & operator << (ostream &output,const point2D &p)
{
output << "("<<p.x<<","<<p.y<<")"<<endl;
return output;
}

回复

使用道具 举报

千问 | 2010-8-29 12:42:36 | 显示全部楼层
class定义末尾漏分号了= =...class point2D//The point in the plane{public: point2D (double x=0,double y=0); void getpoint2D(double,double); double getx() const {return x;} double gety() const {return y;} friend ostream &operator<<(ostream &,const point2D &);protected: double x,y;};//这里补上分号,一切正常...void point2D::getp
回复

使用道具 举报

千问 | 2010-8-29 12:42:36 | 显示全部楼层
#include using namespace std;然后类定义后忘记了分号
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行