2 Star 1 Fork 2

陈首翱 / cppThings

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
stack.cpp 432 Bytes
Copy Edit Raw Blame History
chenshouao authored 2022-01-20 19:37 . initlized
//
// 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);
}
}
1
https://gitee.com/chen-shouao/cpp-things.git
git@gitee.com:chen-shouao/cpp-things.git
chen-shouao
cpp-things
cppThings
master

Search