c语言编程
为什么Microsoft Visual C++ 6.0能编译C语言代码,而不能编译C++代码。如:
#include"iostream.h"
int add(int x,int y)
{
int z;
z=x+y;
return z;
}
void main()
{
int a,b,c;
cin>>a>>b;
c=add(a,b);
cout<<c<<endl;
}
而编译时报错!
--------------------Configuration: cp_1 - Win32 Debug--------------------
Compiling...
test.c
F:\VC 6\MyProjects\cp_1\test.c(13) : error C2065: 'cin' : undeclared identifier
F:\VC 6\MyProjects\cp_1\test.c(13) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
F:\VC 6\MyProjects\cp_1\test.c(15) : error C2065: 'cout' : undeclared identifier
F:\VC 6\MyProjects\cp_1\test.c(15) : error C2065: 'endl' : undeclared identifier
F:\VC 6\MyProjects\cp_1\test.c(15) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
Error executing cl.exe.
test.obj - 3 error(s), 2 warning(s)
求大侠指点,谢谢!