C++头文件出错,。帮我看看

来源:百度知道 编辑:UC知道 时间:2024/05/25 12:24:06
#include <iostream.h>
using namespace std;
int main ()
{int x=1,y=0,a=0,b=0;
switch(x)
{
case 1:
switch(y)
{case 0:a++;break;
case1:b++;break;
}
case 2:a++;b++;break;
case 3:a++;b++;
}
cout<<"a="<<a<<"b="<<b<<endl;
}

总是显示第一行有错

我给你改好了,原因在下面说明了。
#include <iostream>
using namespace std;
int main ()
{int x=1,y=0,a=0,b=0;
switch(x)
{
case 1:
switch(y)
{case 0:a++;break;
case1:b++;break;
}
case 2:a++;b++;break;
case 3:a++;b++;
}
cout<<"a="<<a<<"b="<<b<<endl;
}

你要明白#include<isotream>和#include <iostream.h> 的区别。
#include<isotream>是引用<isotream>库使用的时候#include<isotream>
using namespace std;
而<iostream.h> 是头文件使用的时候不需要加
using namespace std;

#include <iostream.h>
改成
#include <iostream>

是#include <iostream>,不要加.h