博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++一个简单的手柄类模板
阅读量:7237 次
发布时间:2019-06-29

本文共 826 字,大约阅读时间需要 2 分钟。

#ifndef HANDLE_H#define HANDLE_H #include "Animal.h"template 
class Handle{ public: Handle(T *ptr); Handle(const Handle &other); Handle &operator = (const Handle &other); ~Handle(); T *operator->(); private: T *ptr_;};template
inline Handle
::Handle(T *ptr) :ptr_(ptr->copy()){}template
inline Handle
::Handle(const Handle &other) :ptr_(other.ptr_->copy()){}template
inline Handle
&Handle
::operator = (const Handle &other){ if(this != &other){ delete ptr_; ptr_ = other.ptr_->copy(); } return *this;}template
inline Handle
::~Handle(){ delete ptr_;}template
inline T *Handle
::operator -> (){ return ptr_;}#endif /*HANDLE_H*/

版权声明:本文博主原创文章,博客,未经同意不得转载。

你可能感兴趣的文章
Delphi编程 -- 使用CPUID指令获取CPU信息(转自大富翁)
查看>>
Android setRequestedOrientation用法
查看>>
面向对象三大基本特性,五大基本原则
查看>>
更改窗口图标并将其显示在任务栏
查看>>
包含的语句
查看>>
正则表达式-匹配标点符号
查看>>
osworkflow descriptor 解析 重要概念
查看>>
Edmonds_Karp 算法 (转)
查看>>
第一节 接口概述 [转贴]
查看>>
C# Attribute 用法备忘
查看>>
数据结构学习笔记(5.线性表之双向循环链表)
查看>>
智能家居趋势
查看>>
[Leetcode] Pow(x, n)
查看>>
关于Microsoft Speech SDK 中TTS的研究 [转]
查看>>
两个与后台有关的回调处理
查看>>
idhttp.post方式 调用datasnap rest 远程方法
查看>>
Gulp快速入门
查看>>
TClientDataSet的 fastscript封装
查看>>
有用的国外开源项目网址
查看>>
DataGridView 绑定DataTable方式编辑保存的bug?
查看>>