实现一个简单的智能指针
01// helloworld.cpp : 定义控制台应用程序的入口点。
02//
03
04#include "stdafx.h"
05#include
06using namespace std;
07
08//指针类
09class I_Pointer{
10private:
11 int ref_count;
12 int *p;
13 I_Pointer(int *p): p(p), ref_count(1){}; //构造函数
14 ~I_Pointer(){
15 cout<<"Delete shared pointer"<
16 }
17friend
18 class Has_Ptr;
19};
20
21//有指针成员的类
22class Has_Ptr{
23private:
编辑特别推荐: