用dev-c++运行c++时总是出现类似如图的语句是怎么回事
用dev-c++运行c++时总是出现类似如图的语句是怎么回事源代码如下#include<iostream>#include<math.h>usingnamespacest...
用dev-c++运行c++时总是出现类似如图的语句是怎么回事
源代码如下
#include<iostream>#include<math.h>using namespace std;class point{ float x, y;public: point(float xx, float yy) { cout << "point构造函数" << endl; x = xx; y = yy; } point(point &p) { x = p.x; y = p.y; cout << "point拷贝构造函数" << endl; } float getx() { return x; } float gety() { return y; }};class Distance{ point p1, p2; double dist;public: Distance(point a, point b); double getdis() { return dist; }};Distance::Distance(point a, point b) :p1(a), p2(b){ cout << "distance构造函数" << endl; double x = double(p1.getx() - p2.getx()); double y = double(p1.gety() - p2.gety()); dist = sqrt(x*x + y*y);}int main(){ point myp1(1, 1), myp2(4, 5); Distance myd(myp1, myp2); cout << "距离是:" << myd.getdis() << endl;} 展开
源代码如下
#include<iostream>#include<math.h>using namespace std;class point{ float x, y;public: point(float xx, float yy) { cout << "point构造函数" << endl; x = xx; y = yy; } point(point &p) { x = p.x; y = p.y; cout << "point拷贝构造函数" << endl; } float getx() { return x; } float gety() { return y; }};class Distance{ point p1, p2; double dist;public: Distance(point a, point b); double getdis() { return dist; }};Distance::Distance(point a, point b) :p1(a), p2(b){ cout << "distance构造函数" << endl; double x = double(p1.getx() - p2.getx()); double y = double(p1.gety() - p2.gety()); dist = sqrt(x*x + y*y);}int main(){ point myp1(1, 1), myp2(4, 5); Distance myd(myp1, myp2); cout << "距离是:" << myd.getdis() << endl;} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询