VC学习之一

无法打开包括文件:“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;
	}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值