亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? proxy_lab.cpp

?? 設計模式
?? CPP
字號:
// Purpose.  Proxy design pattern lab (reference counting)// // Discussion.  One of the four common situations in which the Proxy pattern is// applicable is as a "smart reference" - a replacement for a bare pointer that// performs additional actions when an object is referenced.  Here, that addi-// tional action is "reference counting".  The original String class becomes// the inner "body" class.  A "count" data member is added to the body class.// A new outer "handle" class is created that contains a pointer to a body// instance.  Body instances common to multiple handle instances are shared by// simply incrementing the reference count.  As these shared references go away,// the reference count is decremented.  When the count goes to zero, the body// instance is freed.  This mechanism allows the "reference counted class" to// perform simple-minded garbage collection on itself.// // Assignment.// o Change the class String to an inner body StringRep.// o Add a count_ private data member to StringRep.  Initialize count_ to 1 in//   the default ctor and the 1-arg ctor.// o Create a new outer handle class String. Make String a friend of StringRep.// o String has one private data member - a pointer to a StringRep (rep_).// o The String default ctor initializes rep_ with 'new StringRep("")'.// o The String 1-arg ctor initializes rep_ with 'new StringRep(arg)'.// o The String copy ctor initializes rep_ with the rep_ of the initializing//   String.  It also increments the count_ of that rep_.// o The String dtor decrements the count_ of rep_ and deletes rep_ if count_//   is 0.
// o The String operator=(): increments the count_ of the "rhs" rep_,
//   decrements the count_ of its own rep_ and deletes rep_ if count_ is 0,
//   assigns the "rhs" rep_ to its own rep_, and returns *this.
// o Add cout statements to String to generate the target output.
// o Make the operator<<() function a friend of both StringRep and String.//   Modify it as necessary.#include <iostream.h>#include <string.h>
class String {
public:
	friend ostream& operator << ( ostream&, String& );
	String() { 
		rep = new StringRep(""); 
        cout << "     String ctor (def):" << endl;
	}
	String(const char * in) { 
		rep = new StringRep( in ) ; 
		cout << "     String ctor: " << in << '.' << endl;
	}
    String(const String& s)  { 
		rep = s.rep;
		s.rep->count++;
		cout << "     String (copy): " << s.rep->str_ << '.' << endl;
	}
	String& operator= ( String& rhs ) {
		if (this == &rhs)  return *this;
		rhs.rep->count++;
		rep->count--;
		if(0 == rep->count ) { if( rep ) delete rep; rep = NULL; }
		rep = rhs.rep;
		return *this;
	}
	~String() {
		rep->count--;
		if(rep->count + 1){
			cout << "      String dtor: " << rep->str_ << ", before decrement, count is " 
				<< rep->count + 1 << endl;			
		}
		if(!rep->count ) { if( rep ) delete rep;}
	}
	
	class StringRep {
	public:
		friend class String;
		//		friend ostream& operator << ( ostream&, String& );
		StringRep() {
			cout << "   StringRep ctor (def):" << endl;
			str_ = NULL;
			count = 1;
		}
		StringRep( const char* in ) {
			cout << "   StringRep ctor: " << in << '.' << endl;
			str_ = new char[strlen(in) + 1];
			strcpy( str_, in );
			count = 1;
		}
		StringRep( StringRep& str ) {
			cout << "   StringRep ctor (copy): " << str.str_ << '.' << endl;
			str_ = new char[strlen(str.str_) + 1];
			strcpy( str_, str.str_ );
			count = 1;
		}
		char *getString()    { return str_; }
		~StringRep() {
			cout << "   StringRep dtor: " << str_ << '.' << endl;
			delete str_;
		}
		StringRep& operator= ( StringRep& rhs ) {
			if (this == &rhs)  return *this;
			delete str_;
			str_ = new char[strlen(rhs.str_) + 1];
			strcpy( str_, rhs.str_ );
			return *this;
		}
	private:
		char*  str_;
		int count;
	};
	private:
		StringRep *rep;
};ostream& operator << ( ostream& os, String& str ) { return os << str.rep->getString(); }void main( void ) {	String  a( "hello" );
	String  b = "world";
	String  c( a );
	String  d = a;
	String  e;
	a = b;
	e = b;	cout << "a is " << a << '.' << endl;	cout << "b is " << b << '.' << endl;	cout << "c is " << c << '.' << endl;	cout << "d is " << d << '.' << endl;	cout << "e is " << e << '.' << endl;}/****** Current output ******///    String ctor: hello.//    String ctor: world.//    String ctor (copy): hello.//    String ctor (copy): hello.//    String ctor (def):// a is world.// b is world.// c is hello.// d is hello.// e is world.//    String dtor: world.//    String dtor: hello.//    String dtor: hello.//    String dtor: world.//    String dtor: world./****** Target output ******///    StringRep ctor: hello.// String ctor: hello.//    StringRep ctor: world.// String ctor: world.// String ctor (copy): hello.// String ctor (copy): hello.//    StringRep ctor: .// String ctor (def)://    StringRep dtor: .// a is world.// b is world.// c is hello.// d is hello.// e is world.// String dtor: world, before decrement, count is 3// String dtor: hello, before decrement, count is 2// String dtor: hello, before decrement, count is 1//    StringRep dtor: hello.// String dtor: world, before decrement, count is 2// String dtor: world, before decrement, count is 1//    StringRep dtor: world.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.日韩在线| 26uuu国产一区二区三区| 久久国产精品免费| 极品少妇xxxx精品少妇| 久久精品噜噜噜成人88aⅴ| 精品粉嫩超白一线天av| 图片区日韩欧美亚洲| 成人黄色小视频| 欧美三级日韩三级| 久久蜜桃香蕉精品一区二区三区| 亚洲私人影院在线观看| 亚洲欧美日韩系列| 精品一区二区三区香蕉蜜桃| 欧美成人精品1314www| 亚洲国产精品av| 久久久久97国产精华液好用吗 | 欧美性受xxxx黑人xyx| 成人精品国产免费网站| 99精品欧美一区二区蜜桃免费| 成人av综合在线| 欧美在线观看18| 91黄色免费版| 欧美成人一级视频| 亚洲激情校园春色| 国产一本一道久久香蕉| 91在线国产观看| 91精品国产美女浴室洗澡无遮挡| 国产亚洲欧美激情| 午夜精品爽啪视频| 日韩精品一区二区三区四区| 91在线云播放| 欧美日韩mp4| 国产高清成人在线| 99综合电影在线视频| 欧美日韩一卡二卡三卡| 26uuu色噜噜精品一区二区| 成人免费一区二区三区视频 | 国产亚洲欧美激情| 亚洲男女一区二区三区| 青娱乐精品视频| 99久精品国产| 精品入口麻豆88视频| 亚洲激情在线播放| 国产一区二区在线观看视频| 91国产成人在线| 久久亚洲一级片| 亚洲一区二区三区在线播放| 国产福利电影一区二区三区| 欧美三级在线视频| 国产精品国产a| 久久国产成人午夜av影院| 欧洲精品中文字幕| 国产精品国产自产拍高清av王其| 日本特黄久久久高潮| 91日韩一区二区三区| 久久久青草青青国产亚洲免观| 亚洲综合色自拍一区| 成人av手机在线观看| 91精品国产免费| 亚洲成人免费在线观看| 91视频精品在这里| 国产日韩欧美综合一区| 久久国产精品无码网站| 91精品在线一区二区| 亚洲大片一区二区三区| 99视频在线观看一区三区| 国产欧美一区二区三区在线老狼| 麻豆成人在线观看| 欧美日韩国产首页| 午夜成人在线视频| 91丝袜国产在线播放| 国产午夜亚洲精品不卡| 国产一区二区福利视频| 精品成人a区在线观看| 国产又黄又大久久| 久久网这里都是精品| 国产一区二区三区综合| 欧美精品一区二区三区蜜桃视频| 青娱乐精品视频在线| 欧美成人精精品一区二区频| 久久国产麻豆精品| 337p粉嫩大胆色噜噜噜噜亚洲 | 亚洲在线免费播放| 欧美亚洲综合色| 亚洲综合激情小说| 制服丝袜国产精品| 久久99精品视频| 国产亚洲欧洲997久久综合| 国产一区二区看久久| 国产欧美日韩另类视频免费观看| 国v精品久久久网| 亚洲美女视频一区| 欧美精品第一页| 韩国视频一区二区| 国产精品不卡一区二区三区| 色94色欧美sute亚洲线路二| 午夜精品久久久久久久久| 欧美一区二区免费观在线| 国产综合色产在线精品| 中文字幕欧美一区| 欧美精选午夜久久久乱码6080| 视频一区二区三区中文字幕| 亚洲精品在线观看网站| 日本道色综合久久| 蜜桃视频在线观看一区| 国产精品欧美综合在线| 欧美色大人视频| 国产精品一区二区久久不卡| 亚洲精品福利视频网站| 日韩视频123| 99国产精品久久久| 麻豆视频一区二区| 亚洲激情中文1区| 精品对白一区国产伦| 在线观看中文字幕不卡| 国产毛片精品视频| 亚洲成av人在线观看| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产三级欧美三级日产三级99| 91美女片黄在线观看| 精品一区二区三区视频在线观看| 亚洲欧美激情小说另类| 久久综合久久久久88| 欧美在线一二三| 国产成人精品网址| 青青草原综合久久大伊人精品优势| 国产欧美日韩卡一| 日韩精品一区二区三区在线 | 国产成人精品一区二区三区网站观看| 日韩一区欧美小说| 亚洲精品在线观| 欧美一区二区二区| 欧美日韩一级片在线观看| 国产91清纯白嫩初高中在线观看| 日韩电影免费在线看| 亚洲精品成人a在线观看| 欧美国产日韩精品免费观看| 精品国产一区二区三区久久久蜜月| 色婷婷av一区二区三区之一色屋| 国产精品一区二区不卡| 欧美一区2区视频在线观看| 性感美女极品91精品| 日韩一级完整毛片| www.欧美色图| 五月天激情小说综合| 久久色在线观看| 在线观看网站黄不卡| 韩国一区二区三区| 日韩精品乱码免费| 欧美国产1区2区| 欧美猛男超大videosgay| 国产一区二区三区最好精华液 | 国产欧美日韩精品在线| 成人aa视频在线观看| 美国十次综合导航| 一区二区三区不卡在线观看 | 久久爱www久久做| 视频一区二区欧美| 久久久国产一区二区三区四区小说 | 亚洲国产一区在线观看| 激情图区综合网| 久久精品人人做人人爽人人| 久久久久国产精品麻豆ai换脸| 久久这里只有精品首页| 久久九九全国免费| 国产精品美女久久久久aⅴ| 国产精品狼人久久影院观看方式| 久久精品在线免费观看| 中文字幕欧美日本乱码一线二线| 国产精品久久一卡二卡| 精品91自产拍在线观看一区| 欧美大白屁股肥臀xxxxxx| 欧美专区在线观看一区| 欧洲精品中文字幕| 欧美日韩一本到| 久久精品视频一区二区三区| 欧美三级电影在线观看| 欧美性一二三区| 日韩精品一区二区三区老鸭窝| 在线免费亚洲电影| 91久久免费观看| 国产精品免费网站在线观看| 色老汉一区二区三区| 国产一区二区视频在线播放| 欧美日韩国产精选| 欧美日本不卡视频| 久久午夜色播影院免费高清 | 亚洲成人免费在线观看| 久久精品国产在热久久| 99热精品国产| 日韩欧美在线一区二区三区| 国产精品视频在线看| 偷窥少妇高潮呻吟av久久免费| 极品尤物av久久免费看| 91在线一区二区三区| 日韩一二三区视频| 亚洲视频香蕉人妖| 精品在线播放午夜| 日本电影亚洲天堂一区| 久久久久国产精品人|