首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

大神们~报错看不懂= =

2012-09-10 
求助大神们~~报错看不懂 #include iostreamvoid MyFunc(void)class Expt{public:Expt(){}~Expt(){}

求助大神们~~报错看不懂= =
#include <iostream>
void MyFunc(void);
class Expt
{
public:
Expt(){};
~Expt(){};
const char *ShowReason() const
{return "Expt类异常";}
};
class Demo{
public:
Demo();
~Demo();
};
Demo::Demo()
{cout<<"构造Demo。"<<endl;
}
Demo::~Demo()
{cout<<"析构 Demo。"<<endl;
}
void MyFunc(){
Demo D;
throw Expt;
}
int main ()
{
cout<<"在main函数中。"<<endl;
try 
{cout<<"在try块中,调用MyFunc()。"<<endl;
MyFunc();
}
catch (Expt E)
{
cout<<"在catch异常处理程序中。"<<endl;
cout<<"捕获到Expt类型异常:";
cout<<E.ShowReason()<<endl;
}
catch(char*str)
{
cout<<"捕获到其他异常:"<<str<<endl;
}
cout<<"回到main函数。从这里恢复运行。"<<endl;
return 0;
}




报错在这里~!
D:\Program Files\Desktop\新建文件夹\ou.cpp(17) : error C2065: 'cout' : undeclared identifier
D:\Program Files\Desktop\新建文件夹\ou.cpp(17) : error C2297: '<<' : illegal, right operand has type 'char [11]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(17) : error C2065: 'endl' : undeclared identifier
D:\Program Files\Desktop\新建文件夹\ou.cpp(20) : error C2297: '<<' : illegal, right operand has type 'char [12]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(24) : error C2275: 'Expt' : illegal use of this type as an expression
  D:\Program Files\Desktop\新建文件夹\ou.cpp(4) : see declaration of 'Expt'
D:\Program Files\Desktop\新建文件夹\ou.cpp(28) : error C2297: '<<' : illegal, right operand has type 'char [15]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(30) : error C2297: '<<' : illegal, right operand has type 'char [26]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(35) : error C2297: '<<' : illegal, right operand has type 'char [24]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(36) : error C2297: '<<' : illegal, right operand has type 'char [21]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(37) : error C2297: '<<' : illegal, right operand has type 'const char *'
D:\Program Files\Desktop\新建文件夹\ou.cpp(41) : error C2297: '<<' : illegal, right operand has type 'char [16]'
D:\Program Files\Desktop\新建文件夹\ou.cpp(43) : error C2297: '<<' : illegal, right operand has type 'char [31]'

[解决办法]
using namespace std;
[解决办法]

C/C++ code
throw Expt(); 

热点排行