返回信息流#include<iostream>
#include<math.h>
using namespace std;
class Point
{
public:
Point(int xx=0,int yy=0)
{X=xx;Y=yy;}
Point(Point &p);
int GetX(){return X;}
int GetY(){return Y;}
private:
int X,Y;
};
Point::Point(Point &p)
{
X=p.X;Y=p.Y;
cout<<"point拷贝构造函数被调用"<<endl;
}
class Distance
{
private:
Point p1,p2;
double dist;
public:
Distance(Point a,Point b);
double GetDis(void)
{
return dist;
};
};
Distance::Distance(Point xp1,Point xp2):p1(xp1),p2(xp2)
{
cout<<"Distance构造函数被调用"<<endl;
double x=double(p1.GetX()-p2.GetX());
double y=double(p1.GetY()-p2.GetY());
dist=sqrt(x*x+y*y);
}
void main()
{
Point myp1(1,1),myp2(4,5);
Distance myd(myp1,myp2);
cout<<"the distance is:";
cout<<myd.GetDis()<<endl;
}
书上的一个例子,在vc下,我用F11和F10分别调试时,总是会弹出一个框框“please enter the path for xxxx(断点设置的位置不一样,所要找的文件也不一样。)
请问是咋个回事啊?
这是一条镜像帖。来源:北邮人论坛 / cpp / #14886同步于 2008/10/29
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
c++调试出问题
dramly
2008/10/29镜像同步14 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
请用gdb
【 在 dramly (风水涧) 的大作中提到: 】
: #include<iostream>
: #include<math.h>
: using namespace std;
: ...................
gdb是一个强大的debugger
【 在 dramly (风水涧) 的大作中提到: 】
: gdb 是啥呢?
: 能尽量用通俗易懂的语言不?
: 呵呵,刚刚学,不大懂
: ...................
昂?头文件没啥问题吧……
【 在 ericyosho (ericyosho) 的大作中提到: 】
: 这一看头文件的写法,就知道是VC啊,你还让人用gdb。
: 找抽……
其实这个在g++里也能编译通过的……嗯……
【 在 ericyosho (ericyosho) 的大作中提到: 】
: #include <cmath>
: LZ写的是math.h
: =。=
: ...................