无法打开包括文件:“iostream.h”报错
VC6写的例子,用VS2008打开,报错fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory
原因是 在VC6下的写法,
#include <iostream.h>
VC9应改为
#include <iostream>
另外,要添加using namespace std;
否则会报 错误 1 fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory
示例如下:
#include "Fish.h"
#include <iostream>
using namespace std;
Fish::Fish():Animal(300,400)
{
}
void Fish::breathe()
{
cout<<"fish bubble"<<endl;
}
VC与C#区别
VC定义一个变量,就会调用此变量的构造函数,不需要显示调用new ,这一点与C#是不同的
例如:void main()
{
Point pt;
pt.output();//pt定义后,就隐式调用了构造函数
pt.output(5,5);
}
VC类中定义成员变量时,不能直接能成员变量赋值,否则会报
错误 1 error C2864: “Point::x”: 只有静态常量整型数据成员才可以在类中初始化例如:
class Point
{
public:
int x=0;//不能直接赋值
int y;
Point()
{
x=0;
y=0;
}