首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

运作以后显示 “distance”: 不明确的符号 是这么回事

2012-11-07 
运行以后显示 “distance”: 不明确的符号是这么回事?#include iostream#include cmathusing namespace

运行以后显示 “distance”: 不明确的符号 是这么回事?
#include <iostream>
#include <cmath>
using namespace std;


class point
{ public:
point (int xi=0,int yi=0) {x=xi;y=yi;}
int getx() {return x;}
int gety() {return y;}
private: int x,y;
};


class distance
{ public:
distance (point xp1,point xp2);
double getdis() {return dist;}
private: point p1,p2;
double dist;
};
distance::distance(point xp1, point xp2):p1(xp1),p2(xp2)
{
double x=double(p1.getx()-p2.getx());
double y=double(p1.gety()-p2.gety());
dist=sqrt(x*x+y*y);
}
int main()
{
point mp1(5,10),mp2(20,30);
distance mdist(mp1,mp2);
cout<<"the distance is:"<<mdist.getdis()<<endl;
}

[解决办法]
std命名空间里已经有了distance这个关键词
[解决办法]
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。

热点排行
Bad Request.