首页 > 试题广场 >

阅读下列程序,写出运行结果: #include us

[问答题]
阅读下列程序,写出运行结果:

#include<iostream>
using namespace std;
void f();
class T
{
public:
T()
{
cout<<"constructor"<<endl;
try
  {
throw  "exception";
}
catch( char * )
  {
cout<<"exception1"<<endl;
}
throw  "exception";
}
~T()
{
cout<<"destructor";
}
};
int main()
{
cout<<"main function "<<endl;
   try
{
f();
}
   catch( char * )
{
cout<<"exception2"<<endl;
}
   cout<<"main function "<<endl;    
}
void f()
{  
T t;  
}

推荐

main function

constructor

exception1

exception2

main function

发表于 2018-05-07 15:30:01 回复(0)