1. 首页
  2. 移动开发
  3. Symbian
  4. 离开作用域时清理资源C++代码

离开作用域时清理资源C++代码

上传者: 2020-10-28 06:57:20上传 RAR文件 1.5KB 热度 15次
如果你不使用智能指针,这个方法将对你有帮助 // 离开作用域时清理p YourClass* p = new YourClass ScopeGuard sg = MakeGuardObject(p); // 离开作用域时清理p数组 YourClass* p = new YourClass[100]; ScopeGuard sg = MakeGuardArray(p); // 离开作用域时调用mutex对象的Lock方法 ScopeGuard sg = MakeGuardMethod(mutex, &Mutex::Lock);
下载地址
用户评论