我在复习c++的时候发现我编写程序的时候用了namespace,不知怎么出错了
不用的时候是可以正常运行的,代码如下:
# include "iostream.h"
int chu(unsigned short x,unsigned short y);
int main()
{
unsigned short x,y;
cout<<"please input x:"<<endl;
cin>>x;
cout<<"please input y:"<<endl;
cin>>y;
cout<<chu(x,y)<<endl;
return 0;
}
int chu(unsigned short x,unsigned short y)
{
if (y==0)
return -1;
else
return(int(x/y));
}
可是用了就抱错:
# include "iostream.h"
int chu(unsigned short x,unsigned short y);
int main()
{
using namespace std;
unsigned short x,y;
cout<<"please input x:"<<endl;
cin>>x;
cout<<"please input y:"<<endl;
cin>>y;
cout<<chu(x,y)<<endl;
return 0;
}
int chu(unsigned short x,unsigned short y)
{
if (y==0)
return -1;
else
return(int(x/y));
}
说不存在std这个标准名称空间。大家说说这是怎么了
回答:
#include <iostream>
不要加 .h