demo.cpp
来自「遗传算法的一个库」· C++ 代码 · 共 33 行
CPP
33 行
#include <GradSoft/ptrs.h>#include <iostream>#include <utility>using namespace GradSoft;int main(int argc, char** argv){ owned_ptr<std::pair<int,int>,ptr::safe> x(new std::pair<int,int>(5,5),true); owned_ptr<std::pair<int,int>,ptr::safe> y(new std::pair<int,int>(4,4),true); owned_ptr<std::pair<int,int>,ptr::unsafe> z(new std::pair<int,int>(4,4),true); x.set(y,true); y.release(); try { std::cout << y->first << std::endl; }catch(const NullPointerException& ex){ std::cout << "Null pointer exception handled" << std::endl; } try { std::cout << x->first << std::endl; }catch(const NullPointerException& ex){ std::cout << "Null pointer exception handled" << std::endl; } return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?