📄 sonyhandle.h
字号:
//=====================================
// sonyhandle.h
//=====================================
#ifndef HEADER_SONYHANDLE
#define HEADER_SONYHANDLE
//-------------------------------------
#include"sony.h"
//-------------------------------------
class SonyHandle{
Sony* sp;
int* count;
public:
SonyHandle(Sony* pp) : sp(pp), count(new int(1)){}
SonyHandle(const SonyHandle& sh):sp(sh.sp),count(sh.count){ (*count)++; }
Sony* operator->(){ return sp; }
SonyHandle& operator=(const SonyHandle& sh){
if(sh.sp == sp) return *this; // 本来就指向同一个对象的情况
(*this).~SonyHandle();
sp = sh.sp;
count = sh.count;
(*count)++;
return *this;
}
~SonyHandle(){
if(--(*count)==0){
delete sp;
delete count;
}
}
};//-----------------------------------
#endif // HEADER_SONYHANDLE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -