What happend: Exception throws in the .ctor()?
2008-06-03 16:12
302 查看
1. If an exception was thrown in a type's .ctor(), then the class's destrutor wouldn't be called.
2. If a exception was catched in a try-catch block, all the well-constructed object will be destructed( destrutor method will be called) before enter the catch section:
try
{
CFoo a;
CFoo b;
throw int();
CFoo c;
}
catch(int& i)
{
//----
}
the destrutor of a, b will be called except c.
3. Any created heap objects will be well-deleted before existing the try block even though an exception occurs.
2. If a exception was catched in a try-catch block, all the well-constructed object will be destructed( destrutor method will be called) before enter the catch section:
try
{
CFoo a;
CFoo b;
throw int();
CFoo c;
}
catch(int& i)
{
//----
}
the destrutor of a, b will be called except c.
3. Any created heap objects will be well-deleted before existing the try block even though an exception occurs.
相关文章推荐
- What happend: Exception throws in the .ctor()?
- c++ what happens when a constructor throws an exception and leaves the object in an inconsistent state?
- In p = new Fred(), does the Fred memory “leak” if the Fred constructor throws an exception?
- What is the difference between a function expression vs declaration in JavaScript?
- java.lang.IllegalArgumentException: The class class ** is not found in EntityFactory.
- What is the best comment in source code you have ever encountered? [closed]
- java.lang.IllegalArgumentException: Invalid character found in the request target. The valid charac
- 托福写作5-what is the most important characteristic that a person can have to be successful in life
- 【Java】Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1099
- What will the following polymorphic code output in C ++
- Describe the process of opening a file in Linux system, what actions the operating system w
- yml配置文件读取出错 Exception in thread "main" while scanning for the next token found character '\t(TAB)'
- atitit.解决net.sf.json.JSONException There is a cycle in the hierarchy
- July Challenge 2017 | Whats in the Name
- What have done in the last 2 days? (2010-10-05)
- In C++, what’s the difference between an inline function and a macro?
- 解决System.Runtime.CompilerServices.ExtensionAttribute..ctor 与 ‘ExtensionAttribute’ is ambiguous in the namespace ‘System.Runtime.CompilerServices’ 问题
- Difference between throw and throws in Exception handling - Java Example
- 1.1 What is the plug-in?
- What the hell is cmp byte ptr[rax],0 in a managed mini dump?