C++ 标准库中的异常
2016-10-28 10:48
176 查看
#include<iostream>
#include <exception>
#include <stdexcept>
using namespace std;
class CException:public std::exception
{
public:
std::string s;
CException(std::string ss):s(ss)
{
}
~CException()throw()
{
}
const char* what() const throw()
{
return s.c_str();
}
};
int main()
{
try
{
throw CException("11");
cout << "end try" << endl;
}
catch(std::exception& e)
{
cout << "CException: " << e.what() << endl;
}
cout << "end" << endl;
}
#include <exception>
#include <stdexcept>
using namespace std;
class CException:public std::exception
{
public:
std::string s;
CException(std::string ss):s(ss)
{
}
~CException()throw()
{
}
const char* what() const throw()
{
return s.c_str();
}
};
int main()
{
try
{
throw CException("11");
cout << "end try" << endl;
}
catch(std::exception& e)
{
cout << "CException: " << e.what() << endl;
}
cout << "end" << endl;
}
相关文章推荐
- C++ 标准库中的异常
- c++标准异常类别
- C++ 标准异常
- C++ 标准库中的异常
- C++中的标准异常类
- c++ 标准异常
- C++ 标准的异常
- c++ 抛出标准异常
- c++ 11 国标标准方面的异常处理与微软在Visual Studio 2012的异常处理的区别
- C++ - 标准异常报错(call to 'std::exception::exception(const char [n])')
- 浅谈C++ 标准库中的异常 —— stdexcept类
- C++标准异常类
- MFC异常 与C++标准异常
- C++标准异常
- C++ 标准异常类
- C++ 11 国标标准方面的异常处理与微软在Visual Studio 2012的异常处理的区别
- c++标准异常类别
- C++ 标准库中的异常 http://blog.csdn.net/hzhxxx/article/details/7616336
- c++ 标准异常类
- C++中的标准异常类