#include<memory>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;
void m()
{
static string msg ;
ostringstream ex_msg;
int a=4;
ex_msg<<"hello is "<<a<<" index_";
msg = ex_msg.str();
cout<<msg<<endl;
//return msg.c_str(); //将string转换成char *
}
void main()
{
vector<string>*ptext =0;
try
{
ptext =new vector<string>;
// ptext =new (nothrow)vector<string>;这种不会有异常抛出,但是如果有异常之后会传回0
m();
}
catch(bad_alloc) //当内存不足的时候调用
{
cout<<"namespace don't enough !"<<endl;
}
catch(const exception &ex) //exception的所有派生类出现错误都能在这里捕捉到
{
cout<<ex.what()<<endl;
}
}