终于开始了C++的学习了,一上来就遇到个问题,严重打击积极性啊,不过softice希望复制在终端技术领域的成功经验,每天进步一点一点,希望用两年的时间对C++熟一点,说说今天遇上的问题吧,先上代码
#include <iostream.h>
struct Point{
int x;
int y;
};
void main()
{
Point pt;
pt.x=5;
pt.y=5
cout<<pt.x<<endl;
cout<<pt.y<<endl;
}
struct Point{
int x;
int y;
};
void main()
{
Point pt;
pt.x=5;
pt.y=5
cout<<pt.x<<endl;
cout<<pt.y<<endl;
}
以上的代码,如果在VS.NET 2003之前编译,可以正常运行并且输入正确的结果,但是在VS.NET 2003及以后,就会报一个错误
c:\users\softice\documents\visual studio 2010\projects\lesson2\lesson2\lesson2.cpp(1): fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory
其实这主要是因为微软将isotream.h实现做了更改,更加接近于标准的C++规范,VS2010中的一个宣传亮点好你就是更加符合标准C++的规范,赞一个先,正确的引用代码
#include
"iostream"
using namespace std;
struct Point {
int x;
int y;
};
void main()
{
Point pt;
pt.x =5;
pt.y =5;
cout<<pt.x<<endl;
cout<<pt.y<<endl;
system( "pause");//屏幕暂停
}
using namespace std;
struct Point {
int x;
int y;
};
void main()
{
Point pt;
pt.x =5;
pt.y =5;
cout<<pt.x<<endl;
cout<<pt.y<<endl;
system( "pause");//屏幕暂停
}
参考文档