smartpointer.cpp
来自「C++高级编程这本书所附的源代码」· C++ 代码 · 共 38 行
CPP
38 行
#include <fstream>#include <iostream>#include <stdexcept>using namespace std;void funcOne() throw(exception);void funcTwo() throw(exception);int main(int argc, char** argv){ try { funcOne(); } catch (exception& e) { cerr << "Exception caught!\n"; exit(1); } return (0);}#include <memory>using namespace std;void funcOne() throw(exception){ string str1; auto_ptr<string> str2(new string("hello")); funcTwo();}void funcTwo() throw(exception){ ifstream istr; istr.open("filename"); throw exception(); istr.close();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?