17 Star 242 Fork 115

Yj / CPlusPlusThings

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
stack.cpp 432 Bytes
一键复制 编辑 原始数据 按行查看 历史
light-city 提交于 2020-03-03 11:13 . update
//
// Created by light on 19-12-9.
//
#include <iostream>
class Obj {
public:
Obj() { puts("Obj()"); }
~Obj() { puts("~Obj()"); }
};
void foo(int n)
{
Obj obj;
if (n == 42)
throw "life, the universe and everything";
}
// 不管是否发生了异常,obj 的析构函数都会得到执行。
int main()
{
try {
foo(41);
foo(42);
}
catch (const char* s) {
puts(s);
}
}
C++
1
https://gitee.com/yj404/CPlusPlusThings.git
git@gitee.com:yj404/CPlusPlusThings.git
yj404
CPlusPlusThings
CPlusPlusThings
master

搜索帮助