请教一个问题,能快点给我帮助吗
#include <iostream.h>int main()
{
int a;
cout<<"请输入一个数字,按回车结束"<<endl;
cin>> a;
cout<<a<<endl;
return 0;
}
在编译时会出现如下提示:
:\lxc\study\l.c(5) : error C2065: 'cout' : undeclared identifier
d:\lxc\study\l.c(5) : error C2297: '<<' : illegal, right operand has type 'char [27]'
d:\lxc\study\l.c(5) : error C2065: 'endl' : undeclared identifier
d:\lxc\study\l.c(6) : error C2065: 'cin' : undeclared identifier
d:\lxc\study\l.c(6) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
d:\lxc\study\l.c(7) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
而<iostream>要指定命名空间
楼主的问题应该是编译器的问题 1."iostream.h"是基于C语言的头文件,而
“iostream”是C++的标准格式。
2.两者都可在vc++中使用,但后者必须使用命名空间
即 using namespace std;已解决重名冲突的问题。
3.你的程序没有错误,可能是编译器的问题
或着你可以再建一个工程,创建C++文件,在进行编译一次。
页:
[1]
