各位老师同学大家好,今天在调试以下代码:
#include <iostream.h>
struct point
{
int x;
int y;
void output()
{
cout<<x<<endl<<y<<endl;
}
};
struct point
{
int x;
int y;
void output()
{
cout<<x<<endl<<y<<endl;
}
};
void main()
{
point pt;
pt.x=0;
pt.y=0;
// cout<<pt.x<<endl<<pt.y<<endl;
pt.output();
}
{
point pt;
pt.x=0;
pt.y=0;
// cout<<pt.x<<endl<<pt.y<<endl;
pt.output();
}
首先出现的是头部文件的问题,在网上查找了相关的资料,已经了解了在标准C++里面,是不用#include <iostream.h>这种形式了,而要使用#include <iostream> 因此,把上面的第一行代码#include <iostream.h> 改成如下等式解决了编译出错的问题:
#include <iostream>
using namespase std;
但我把上面的代码替换后,编译没有出错,但是运行时弹出窗口一闪就没了,不知为何?请各位老师和同学指点一下!谢谢!下面是我新建项目的截图: