forked from Light-City/CPlusPlusThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f98a4ce
commit 3ae20ae
Showing
6 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(Morden_C++) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
# boost | ||
set(BOOST_INCLUDE_DIR /home/light/bst/include) | ||
set(BOOST_LINK_DIR /home/light/bst/lib) | ||
|
||
# 去哪里找头文件 相当于gcc/clang 中的-I(i的大写字母)参数 | ||
include_directories(${BOOST_INCLUDE_DIR}) | ||
# 去哪里找库文件 .so .dll .dylib 相当于gcc 中的-L参数 | ||
link_directories(${BOOST_LINK_DIR}) | ||
|
||
add_executable(heap RAII/heap.cpp) | ||
add_executable(stack RAII/stack.cpp) | ||
add_executable(RAII RAII/RAII.cpp) | ||
add_executable(auto_ptr smart_ptr/auto_ptr.cpp) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// 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); | ||
} | ||
} |