Throw an exception while construct an object
来源:互联网 发布:数控编程用什么软件好 编辑:程序博客网 时间:2024/04/30 02:35
while reading the book < thinking in c++ 2>, I got the codes below:
#include <stdlib.h>
#include <iostream>
#pragma warning(disable : 4297)
using namespace std;
class buffer
{
public:
explicit buffer(size_t) throw();
~buffer() throw();
private:
char *const p;
};
buffer::buffer(size_t const count)
try
: p(new char[count])
{
cout << "constructor goes well......" << endl;
}
catch (...)
{
throw "hello";
abort();
}
buffer::~buffer()
{
delete[] p;
cout << "destructor also goes well......" << endl;
}
static void do_something_with(buffer &) throw()
{
cout << "something is done !" << endl;
}
int main()
{
buffer b(100);
do_something_with(b);
return 0;
}
- Throw an exception while construct an object
- throw an exception
- Mocking a method to throw an exception in C#
- BEA-149500:An exception occurred while registering the MBean null
- An exception has been caught while processing the refactoring 'Delete'.
- eclipse 错误:An unexpected exception occurred while performing the refactoring ...
- How can I throw an exception without losing the original stack trace information in .NET?
- Why doesn't incrementing Nullable<int> throw an exception?(stackoverflow)
- an exception occur reason
- Encryption raised an exception
- Locking an Object
- An NSLock object
- An NSNotificationCenter object
- An NSMethodSignature object
- getFiled of an object
- Using an NSAnimation Object
- Serialization:Serializing an Object
- Everything Is an Object
- D3D中的第一人称视角
- Java深入探索之道Java类加载机制的奥秘
- 过完年终于回来了.
- 一道sql面试题
- 表单精确验证代码
- Throw an exception while construct an object
- 新年新气象
- 远程桌面 Web 连接-http://blog.an85.com/3389/Default.htm
- java游戏开发计划
- 勿在浮沙筑高楼:给编程入门者的建议
- "即使我们不去拜靖国神社韩国人也不会买我们的产品,但不管我们再怎样的去拜靖国神社,中国人照样会买我们的产品。"
- [转贴] debug与release的区别
- HRESULT SetRenderState( D3DRENDERSTATETYPE State, DWORD Value )
- [笔记] SWT编程中的注意事项