﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-c++探索-随笔分类-c++</title><link>http://www.cppblog.com/bloodsuck/category/1859.html</link><description>玩玩</description><language>zh-cn</language><lastBuildDate>Thu, 22 May 2008 12:47:30 GMT</lastBuildDate><pubDate>Thu, 22 May 2008 12:47:30 GMT</pubDate><ttl>60</ttl><item><title>1个形式怪异的函数</title><link>http://www.cppblog.com/bloodsuck/archive/2007/06/12/26156.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Tue, 12 Jun 2007 08:09:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2007/06/12/26156.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/26156.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2007/06/12/26156.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/26156.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/26156.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;&nbsp;backarry(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;arrayname&nbsp;)[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">])&nbsp;)&nbsp;&nbsp;[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>{<br></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;arrayname;<br></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>};</span></div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 呵呵，是有点古怪 <br><br>&nbsp; 再来个<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;&nbsp;backarry(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;arrayname&nbsp;)[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">])&nbsp;)&nbsp;&nbsp;[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>{<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;arrayname;<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>};<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">&nbsp;&nbsp;backarry(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">&nbsp;arrayname)[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]))[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>{<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">;</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">i)<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;{<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">i;<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;arrayname;<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>};<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>{<br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">array</span><span style="COLOR: #000000">[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">};<br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>backarry(</span><span style="COLOR: #0000ff">array</span><span style="COLOR: #000000">);</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">会调用哪个呢？？<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>}</span></div>
<img src ="http://www.cppblog.com/bloodsuck/aggbug/26156.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2007-06-12 16:09 <a href="http://www.cppblog.com/bloodsuck/archive/2007/06/12/26156.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个 Decorator 模式 例子（原）</title><link>http://www.cppblog.com/bloodsuck/archive/2007/03/22/20338.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Thu, 22 Mar 2007 01:56:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2007/03/22/20338.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/20338.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2007/03/22/20338.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/20338.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/20338.html</trackback:ping><description><![CDATA[
		<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#pragma once<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />class component<br /></span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    component(void);<br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  virtual void printsefl()</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">   ;<br /></span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    virtual ~component(void);<br /></span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />};<br /></span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">12</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />class concreatecom :</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> component<br /></span>
				<span style="COLOR: #008080">13</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    concreatecom(char</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> );<br /></span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  virtual void printsefl()   ;<br /></span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  virtual ~concreatecom(void);<br /></span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />protected:<br /></span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">20</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />char </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> _psz_text;<br /></span>
				<span style="COLOR: #008080">21</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />};<br /></span>
				<span style="COLOR: #008080">22</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">23</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />class decorator:</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> component<br /></span>
				<span style="COLOR: #008080">24</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">25</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">26</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />     decorator(component</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">);<br /></span>
				<span style="COLOR: #008080">27</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  virtual void printsefl()     ;<br /></span>
				<span style="COLOR: #008080">28</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  virtual ~decorator();<br /></span>
				<span style="COLOR: #008080">29</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />protected:<br /></span>
				<span style="COLOR: #008080">30</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">31</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">32</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   component </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> _pcomponent;<br /></span>
				<span style="COLOR: #008080">33</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />};<br /></span>
				<span style="COLOR: #008080">34</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />class  headdeco:</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> decorator<br /></span>
				<span style="COLOR: #008080">35</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">36</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">37</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />       headdeco(component</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">);<br /></span>
				<span style="COLOR: #008080">38</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   virtual void printsefl()   ;<br /></span>
				<span style="COLOR: #008080">39</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   virtual ~headdeco();<br /></span>
				<span style="COLOR: #008080">40</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />protected:<br /></span>
				<span style="COLOR: #008080">41</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    virtual void printhead()  ;<br /></span>
				<span style="COLOR: #008080">42</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">43</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> _i_head;<br /></span>
				<span style="COLOR: #008080">44</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />};<br /></span>
				<span style="COLOR: #008080">45</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">46</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />class enddeco:</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> decorator<br /></span>
				<span style="COLOR: #008080">47</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">48</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">49</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />      enddeco(component</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">,char</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">);<br /></span>
				<span style="COLOR: #008080">50</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    virtual void printsefl() ;<br /></span>
				<span style="COLOR: #008080">51</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    virtual  ~enddeco();<br /></span>
				<span style="COLOR: #008080">52</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />protected:<br /></span>
				<span style="COLOR: #008080">53</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />      virtual void printend() ;<br /></span>
				<span style="COLOR: #008080">54</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">private</span>
				<span style="COLOR: #000000">:<br /></span>
				<span style="COLOR: #008080">55</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> char</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> _pch_end;<br /></span>
				<span style="COLOR: #008080">56</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />};</span>
		</div>
		<br />
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">StdAfx.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">component.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />using namespace std;<br /></span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />component::component(void)<br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />component::~component(void)<br /></span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">12</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">13</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void concreatecom::printsefl() <br /></span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">_psz_text ;<br /></span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">20</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> concreatecom::concreatecom(char</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> psz)<br /></span>
				<span style="COLOR: #008080">21</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">22</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />      _psz_text</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">psz;<br /></span>
				<span style="COLOR: #008080">23</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">24</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> decorator::decorator(component</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> a):<br /></span>
				<span style="COLOR: #008080">25</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   _pcomponent(a)<br /></span>
				<span style="COLOR: #008080">26</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">27</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  <br /></span>
				<span style="COLOR: #008080">28</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">29</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />concreatecom::~concreatecom()<br /></span>
				<span style="COLOR: #008080">30</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">31</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">32</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">33</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void decorator::printsefl()<br /></span>
				<span style="COLOR: #008080">34</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">35</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />_pcomponent.printsefl();<br /></span>
				<span style="COLOR: #008080">36</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    <br /></span>
				<span style="COLOR: #008080">37</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">38</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">39</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />decorator::~decorator()<br /></span>
				<span style="COLOR: #008080">40</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">41</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">42</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">43</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">44</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> headdeco::headdeco(component </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> refcom, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i):<br /></span>
				<span style="COLOR: #008080">45</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />  decorator(refcom)<br /></span>
				<span style="COLOR: #008080">46</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> ,_i_head(i)<br /></span>
				<span style="COLOR: #008080">47</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">48</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">49</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">50</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void headdeco::printsefl() <br /></span>
				<span style="COLOR: #008080">51</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{ <br /></span>
				<span style="COLOR: #008080">52</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   printhead();<br /></span>
				<span style="COLOR: #008080">53</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   decorator::printsefl();<br /></span>
				<span style="COLOR: #008080">54</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   <br /></span>
				<span style="COLOR: #008080">55</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">56</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void headdeco::printhead() <br /></span>
				<span style="COLOR: #008080">57</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">58</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">59</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">_i_head;<br /></span>
				<span style="COLOR: #008080">60</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">61</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">62</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />headdeco::~headdeco()<br /></span>
				<span style="COLOR: #008080">63</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">64</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> <br /></span>
				<span style="COLOR: #008080">65</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">66</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">67</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />enddeco::enddeco(component </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> refcom,char </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> pch)<br /></span>
				<span style="COLOR: #008080">68</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />:decorator(refcom)<br /></span>
				<span style="COLOR: #008080">69</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />,_pch_end(pch)<br /></span>
				<span style="COLOR: #008080">70</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">71</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />   <br /></span>
				<span style="COLOR: #008080">72</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">73</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void enddeco::printsefl() <br /></span>
				<span style="COLOR: #008080">74</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">75</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    decorator::printsefl();<br /></span>
				<span style="COLOR: #008080">76</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    printend();<br /></span>
				<span style="COLOR: #008080">77</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">78</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />void enddeco::printend()  <br /></span>
				<span style="COLOR: #008080">79</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">80</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">81</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">_pch_end;<br /></span>
				<span style="COLOR: #008080">82</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    cout</span>
				<span style="COLOR: #000000">&lt;&lt;</span>
				<span style="COLOR: #000000">endl;<br /></span>
				<span style="COLOR: #008080">83</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">84</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />enddeco::~enddeco()<br /></span>
				<span style="COLOR: #008080">85</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">86</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">87</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}</span>
		</div>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">//</span>
				<span style="COLOR: #000000"> decorator.cpp : 定义控制台应用程序的入口点。<br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">//</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">stdafx.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">component.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />using namespace std;<br /></span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> void printmodel(component</span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> pcom )<br /></span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    pcom.printsefl();<br /></span>
				<span style="COLOR: #008080">12</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">13</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> _tmain(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> argc, _TCHAR</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000"> argv[])<br /></span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />{<br /></span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />     <br /></span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    printmodel(headdeco(headdeco(enddeco(concreatecom(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">正文输出中。。。。</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">),</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">黄大仙</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">),</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">),</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">));<br /></span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    return </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /></span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>
				<br />
				<br />       这个decorator 模式例子让初学者 更能加深 多态威力的体会和 decorator 模式 比子类灵活的体会<br />要注意的问题是：对象链总是在 concreatecomponent  对象处结束。<br /><br />  ///此处是client 使用 对象的入口点，仅仅得到了 1个 decorator 的派生类对象，client 什么都不知道<br />printmodel(headdeco(headdeco(enddeco(concreatecom("正文输出中。。。。"),"黄大仙"),2),1));<br />///<br /></p>
		<p>     在vc2005 下通过<br /></p>
<img src ="http://www.cppblog.com/bloodsuck/aggbug/20338.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2007-03-22 09:56 <a href="http://www.cppblog.com/bloodsuck/archive/2007/03/22/20338.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL container  </title><link>http://www.cppblog.com/bloodsuck/archive/2006/09/18/12667.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Mon, 18 Sep 2006 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/09/18/12667.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/12667.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/09/18/12667.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/12667.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/12667.html</trackback:ping><description><![CDATA[    
<p>Containers in STL can be divided into three categories:<br />1.sequence containers,<br />2.associative containers,<br />3.container adapters. <br /><br />1.Sequence Containers</p><div class="section" id="sectionSection0" name="collapseableSection"><p>Sequence containers maintain the original ordering of inserted elements. This allows you to specify where to insert the element in the container.</p><p>The <b>deque</b> (double-ended queue) container allows for fast insertions and deletions at the beginning and end of the container. You can also randomly access any element quickly.</p><p>The <b>list</b> container allows for fast insertions and deletions anywhere in the container, but you cannot randomly access an element in the container.</p><p>The <b>vector</b> container behaves like an array, but will automatically grow as required.</p><p>For more information on the sequence containers, consult the following table:</p><div class="labelheading"><b></b></div><div class="tableSection"><table cellspacing="2" cellpadding="5" width="100%"><tbody><tr><th>Sequence Container </th><th>Native STL </th></tr><tr><td><p><b>deque</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/64842ee5-057a-4063-8c16-4267a0332584.htm"><font color="#002c99">deque Class</font></a></p></td></tr><tr><td><p><b>ilist</b></p></td><td><p>Not Applicable</p></td></tr><tr><td><p><b>list</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/d3707f4a-10fd-444f-b856-f9ca2077c1cd.htm"><font color="#002c99">list Class</font></a></p></td></tr><tr><td><p><b>vector</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/a3e0a8f8-7565-4fe0-93e4-e4d74ae1b70d.htm"><font color="#002c99">vector Class</font></a><br /></p></td></tr></tbody></table></div></div>2.Associative Containers 
<div class="section" id="sectionSection1" name="collapseableSection"><p>The defining characteristic of associative containers is that elements are inserted in a pre-defined order, such as sorted ascending.</p><p>The associative containers can be grouped into two subsets: maps and sets. A <b>map</b>, sometimes referred to as a dictionary, consists of a key/value pair. The key is used to order the sequence, and the value is somehow associated with that key. For example, a <b>map</b> might contain keys representing every unique word in a text and values representing the number of times that word appears in the text. A <b>set</b> is simply an ascending container of unique elements.</p><p>Both <b>map</b> and <b>set</b> only allow one instance of a key or element to be inserted into the container. If multiple instances of elements are required, use <b>multimap</b> or <b>multiset</b>.</p><p>Both maps and sets support bidirectional iterators. For more information on iterators, see <a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/2f746be7-b37d-4bfc-bf05-be4336ca982f.htm"><font color="#002c99">Iterators</font></a>.</p><p>While not officially part of the STL standard, <b>hash_map</b> and <b>hash_set</b> are commonly used to improve searching times. These containers store their elements as a hash table, with each table entry containing a bidirectional linked list of elements. To ensure the fastest search times, make sure that the hashing algorithm for your elements returns evenly distributed hash values.</p><p>For more information on the associative containers, consult the following table:</p><div class="labelheading"><b></b></div><div class="tableSection"><table cellspacing="2" cellpadding="5" width="100%"><tbody><tr><th>Associative Container </th><th>Native STL </th></tr><tr><td><p><b>hash_map</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/40879dfc-51ba-4a59-9f9e-26208de568a8.htm"><font color="#002c99">hash_map Class</font></a></p></td></tr><tr><td><p><b>hash_multimap</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/f41a6db9-67aa-43a3-a3c5-dbfe9ec3ae7d.htm"><font color="#002c99">hash_multimap Class</font></a></p></td></tr><tr><td><p><b>hash_multiset</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/0580397a-a76e-40ad-aea2-5c6f3a9d0a21.htm"><font color="#002c99">hash_multiset Class</font></a></p></td></tr><tr><td><p><b>hash_set</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/c765c06e-cbb6-48c2-93ca-d15468eb28d7.htm"><font color="#002c99">hash_set Class</font></a></p></td></tr><tr><td><p><b>map</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/7876f4c9-ebb4-4878-af1e-09364c43af0a.htm"><font color="#002c99">map Class</font></a></p></td></tr><tr><td><p><b>multimap</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/8796ae05-37c4-475a-9e61-75fde9d4a463.htm"><font color="#002c99">multimap Class</font></a></p></td></tr><tr><td><p><b>multiset</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/630e8c10-0ce9-4ad9-8d79-9e91a600713f.htm"><font color="#002c99">multiset Class</font></a></p></td></tr><tr><td><p><b>set</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/8991f9aa-5509-4440-adc1-371512d32018.htm"><font color="#002c99">set Class</font></a></p></td></tr></tbody></table></div></div><br /><br />3.Container Adapters 
<div class="section" id="sectionSection2" name="collapseableSection"><p>The container adapters are simply variations of the above containers. The container adapters do not support iterators.</p><p>The <b>priority_queue</b> container organized such that the element with the highest value is always first in the queue.</p><p>The <b>queue</b> container follows FIFO (first in, first out) semantics. The first element inserted (pushed) into the queue is the first to be removed (popped).</p><p>The <b>stack</b> container follows LIFO (last in, first out) semantics. The last element to be inserted (pushed) on the stack is the first element to be removed (popped).</p><p>Since container adapters do not support iterators, they cannot be used with the STL algorithms. For more information on algorithms, see <a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/dec9b373-7d5c-46cc-b7d2-21a938ecd0a6.htm"><font color="#002c99">Algorithms</font></a>.</p><p>For more information on the container adapters, consult the following table:</p><div class="labelheading"><b></b></div><div class="tableSection"><table cellspacing="2" cellpadding="5" width="100%"><tbody><tr><th>Container Adapter </th><th>Native STL </th></tr><tr><td><p><b>priority_queue</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/69fca9cc-a449-4be4-97b7-02ca5db9cbb2.htm"><font color="#002c99">priority_queue Class</font></a></p></td></tr><tr><td><p><b>queue</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/28c20ab0-3a72-4185-9e0f-5a44eea0e204.htm"><font color="#002c99">queue Class</font></a></p></td></tr><tr><td><p><b>stack</b></p></td><td><p><a href="ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_vcstdlib/html/02151c1e-eab0-41b8-be94-a839ead78ecf.htm"><font color="#002c99">stack Class</font></a></p></td></tr></tbody></table></div></div><br /><br /><br />Requirements for Container Elements 
<div class="section" id="sectionSection3" name="collapseableSection"><p>Elements inserted into an STL container can be of any object type that supplies a public copy constructor, a public <br />                                      public 拷贝构造 ，public 析构 ,public 赋值操作符   elem&amp; operator =( elem const &amp;)<br />destructor, and a public assignment operator. The destructor may not throw an exception. Furthermore, associative <br />                                                                       析构不能抛出异常<br />containers such as <b>set</b> and <b>map</b> must have a public comparison operator defined, which is operator&lt; by default. Some <br />                             关联容器  除此外 还应由有 比较操作符<br />                  operations on containers might also require a public default constructor and a public equivalence operator.<br /><br /><br /><br /><br />以下是  各容器 迭代器类型输出代码<br /></p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">list</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">deque</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">set</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">map</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">typename inputitrator </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> predict(inputitrator  a)<br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img id="Codehighlighter1_166_267_Open_Image" onclick="this.style.display='none'; Codehighlighter1_166_267_Open_Text.style.display='none'; Codehighlighter1_166_267_Closed_Image.style.display='inline'; Codehighlighter1_166_267_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_166_267_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_166_267_Closed_Text.style.display='none'; Codehighlighter1_166_267_Open_Image.style.display='inline'; Codehighlighter1_166_267_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_166_267_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_166_267_Open_Text"><span style="COLOR: #000000">{   iterator_traits</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">inputitrator</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::iterato_category  b;<br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   <br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> endl</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">typeid(b).name();<br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />main()<br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img id="Codehighlighter1_279_479_Open_Image" onclick="this.style.display='none'; Codehighlighter1_279_479_Open_Text.style.display='none'; Codehighlighter1_279_479_Closed_Image.style.display='inline'; Codehighlighter1_279_479_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_279_479_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_279_479_Closed_Text.style.display='none'; Codehighlighter1_279_479_Open_Image.style.display='inline'; Codehighlighter1_279_479_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_279_479_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_279_479_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  vector</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> a;<br /></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  deque</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> b;<br /></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  list</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> c;<br /></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span><span style="COLOR: #0000ff">set</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> d;<br /></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  map</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> e;<br /></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />  <br /></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   predict(a.begin());<br /></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   predict(b.begin());<br /></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />   predict(c.begin());<br /></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    predict(d.begin());<br /></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     predict(e.begin());<br /></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div></div><pre>output iterator
   -&gt; forward iterator
   -&gt; bidirectional iterator
   -&gt; random-access iterator<br /><br /><pre>input iterator
   -&gt; forward iterator
   -&gt; bidirectional iterator
   -&gt; random-access iterator</pre></pre><img src ="http://www.cppblog.com/bloodsuck/aggbug/12667.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-09-18 10:43 <a href="http://www.cppblog.com/bloodsuck/archive/2006/09/18/12667.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC 中 命令消息传递 （原创）</title><link>http://www.cppblog.com/bloodsuck/archive/2006/07/27/10575.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Thu, 27 Jul 2006 03:27:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/07/27/10575.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/10575.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/07/27/10575.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/10575.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/10575.html</trackback:ping><description><![CDATA[                        先对对于mfc中的命令消息路由的机制原理作个简单的总结：<br />      CCmdTarget 为 模板 ，提供： CCmdTarget::OnCmdMsg() 这个函数 对 其派生类 的消息结构数组（它是静态的）做搜索 并向上（基类）的结构数组做搜索并调用相应的成员函数。<br />   派生类使用 <br /> DECLARE_MESSAGE_MAP()<br />BEGIN_MESSAGE_MAP(本类, 基类)<br /> ON_COMMAND(ID_APP_ABOUT, OnAppAbout)<br />END_MESSAGE_MAP()<br />加入链表<br /><br />        AfxWndProc （只有发向窗口才会被调用），此函数 将使用HWND 在 mfc库的全局变量中<br />找到句柄映射表，转为 CWnd 型 ，最终使用 派生类的对OnCmdMsg()的重载 来实现 不同的路由<br /><br />     以上原理<br />           做为一个例子，将给出个示例：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> CMan : </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> CCmdTarget<br /></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img id="Codehighlighter1_31_284_Open_Image" onclick="this.style.display='none'; Codehighlighter1_31_284_Open_Text.style.display='none'; Codehighlighter1_31_284_Closed_Image.style.display='inline'; Codehighlighter1_31_284_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_31_284_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_31_284_Closed_Text.style.display='none'; Codehighlighter1_31_284_Open_Image.style.display='inline'; Codehighlighter1_31_284_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_31_284_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_31_284_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    DECLARE_DYNAMIC(CMan)<br /></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br /></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    CMan();<br /></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">virtual</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">~</span><span style="COLOR: #000000">CMan();<br /></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000">:<br /></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    DECLARE_MESSAGE_MAP()<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">:<br /></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    afx_msg </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> OnAppAbout();<br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">virtual</span><span style="COLOR: #000000"> BOOL OnCmdMsg(UINT nID, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nCode, </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> pExtra, AFX_CMDHANDLERINFO</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> pHandlerInfo);<br /></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> m_id;<br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    CString m_name;<br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img id="Codehighlighter1_286_357_Open_Image" onclick="this.style.display='none'; Codehighlighter1_286_357_Open_Text.style.display='none'; Codehighlighter1_286_357_Closed_Image.style.display='inline'; Codehighlighter1_286_357_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_286_357_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_286_357_Closed_Text.style.display='none'; Codehighlighter1_286_357_Open_Image.style.display='inline'; Codehighlighter1_286_357_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />}</span></span><span style="COLOR: #000000">;</span><span id="Codehighlighter1_286_357_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id="Codehighlighter1_286_357_Open_Text"><span style="COLOR: #808080">////////////</span><span style="COLOR: #008000">自定义的c++类<br /></span><span style="COLOR: #008080">17</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">18</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">19</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /></span><span style="COLOR: #808080">///////////////</span><span style="COLOR: #008000">/重载 onCmdMsg，（m_man为CMainFram的成员）</span><span style="COLOR: #808080"></span></span><br /><span style="COLOR: #008080">20</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">BOOL CMainFrame::OnCmdMsg(UINT nID, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> nCode, </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> pExtra, AFX_CMDHANDLERINFO</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> pHandlerInfo)<br /></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img id="Codehighlighter1_453_656_Open_Image" onclick="this.style.display='none'; Codehighlighter1_453_656_Open_Text.style.display='none'; Codehighlighter1_453_656_Closed_Image.style.display='inline'; Codehighlighter1_453_656_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_453_656_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_453_656_Closed_Text.style.display='none'; Codehighlighter1_453_656_Open_Image.style.display='inline'; Codehighlighter1_453_656_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_453_656_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_453_656_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> TODO: 在此添加专用代码和/或调用基类</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">23</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">          </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (m_man.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo ))<br /></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img id="Codehighlighter1_556_587_Open_Image" onclick="this.style.display='none'; Codehighlighter1_556_587_Open_Text.style.display='none'; Codehighlighter1_556_587_Closed_Image.style.display='inline'; Codehighlighter1_556_587_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_556_587_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_556_587_Closed_Text.style.display='none'; Codehighlighter1_556_587_Open_Image.style.display='inline'; Codehighlighter1_556_587_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />          </span><span id="Codehighlighter1_556_587_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_556_587_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />              </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />          }</span></span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);<br /></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img id="Codehighlighter1_658_684_Open_Image" onclick="this.style.display='none'; Codehighlighter1_658_684_Open_Text.style.display='none'; Codehighlighter1_658_684_Closed_Image.style.display='inline'; Codehighlighter1_658_684_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_658_684_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_658_684_Closed_Text.style.display='none'; Codehighlighter1_658_684_Open_Image.style.display='inline'; Codehighlighter1_658_684_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_658_684_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id="Codehighlighter1_658_684_Open_Text"><span style="COLOR: #808080">////////////</span><span style="COLOR: #008000">//给CMan 加个命令响应</span><span style="COLOR: #808080"></span></span><br /><span style="COLOR: #008080">31</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">BEGIN_MESSAGE_MAP(CMan, CCmdTarget)<br /></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    ON_COMMAND(ID_APP_ABOUT, OnAppAbout)<br /></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />END_MESSAGE_MAP()<br /></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> CMan 消息处理程序</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">38</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> CMan::OnAppAbout()<br /></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img id="Codehighlighter1_820_919_Open_Image" onclick="this.style.display='none'; Codehighlighter1_820_919_Open_Text.style.display='none'; Codehighlighter1_820_919_Closed_Image.style.display='inline'; Codehighlighter1_820_919_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_820_919_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_820_919_Closed_Text.style.display='none'; Codehighlighter1_820_919_Open_Image.style.display='inline'; Codehighlighter1_820_919_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_820_919_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_820_919_Open_Text"><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> TODO: 在此添加命令处理程序代码</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">42</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">    CString str;<br /></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    str.Format(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,m_id);<br /></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    str</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">m_name;<br /></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    AfxMessageBox(str);<br /></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img id="Codehighlighter1_921_932_Open_Image" onclick="this.style.display='none'; Codehighlighter1_921_932_Open_Text.style.display='none'; Codehighlighter1_921_932_Closed_Image.style.display='inline'; Codehighlighter1_921_932_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_921_932_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_921_932_Closed_Text.style.display='none'; Codehighlighter1_921_932_Open_Image.style.display='inline'; Codehighlighter1_921_932_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_921_932_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id="Codehighlighter1_921_932_Open_Text"><span style="COLOR: #808080">/////////</span><span style="COLOR: #008000">//</span><span style="COLOR: #808080"></span></span><br /><span style="COLOR: #008080">48</span><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />运行后就会发现 此命令将由CMan::onAppAbout() 来 <br /></span><span style="COLOR: #008080">50</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />响应</span></div><img src ="http://www.cppblog.com/bloodsuck/aggbug/10575.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-07-27 11:27 <a href="http://www.cppblog.com/bloodsuck/archive/2006/07/27/10575.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>聚合</title><link>http://www.cppblog.com/bloodsuck/archive/2006/07/05/9422.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Wed, 05 Jul 2006 03:45:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/07/05/9422.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/9422.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/07/05/9422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/9422.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/9422.html</trackback:ping><description><![CDATA[            重用的另一种方法<br />      a 聚合 b<br />    b 要有必要的支持才能实现，具体过程如：<br />     a, cocreateinstance,指定 自己的IUnknown  ,并必须在iid,ppv中指定是 IID__IUnknown ,IUnknown*（被聚合的com类的 非委托IUnknown）<br />此时 被聚合类 在类厂（createinstance 中 接收 a的 IUnknown  并在 b 的成员中赋好值）支持下，被创建<br />的com类 被创建。<br />      b 中 2组 IUnknown 接口：委托（聚合） 和   非委托（正常）<br />    在a 中获取 IUnknown接口（b的），请求 其他 接口时 ( a把 客户发出的对b 的接口请求 转到  a 获取<br /> IUnknown 接口 调用 queryinterface ),全部使用  b 对象 的  委托接口  来判断  是把接口请求 转到 <br />非委托 还是 外部  a 的IUnknown<br /><img src ="http://www.cppblog.com/bloodsuck/aggbug/9422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-07-05 11:45 <a href="http://www.cppblog.com/bloodsuck/archive/2006/07/05/9422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个包容重用</title><link>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9383.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Tue, 04 Jul 2006 08:20:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9383.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/9383.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9383.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/9383.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/9383.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1								#pragma once				  2																		static				 				const				 GUID CLSID_mydiv 				=				 				  3																																												{ 			...&nbsp;&nbsp;<a href='http://www.cppblog.com/bloodsuck/archive/2006/07/04/9383.html'>阅读全文</a><img src ="http://www.cppblog.com/bloodsuck/aggbug/9383.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-07-04 16:20 <a href="http://www.cppblog.com/bloodsuck/archive/2006/07/04/9383.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Run time type Information</title><link>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9360.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Tue, 04 Jul 2006 02:23:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9360.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/9360.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/07/04/9360.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/9360.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/9360.html</trackback:ping><description><![CDATA[
		<dd>
				<b>
						<br />一                 dynamic_cast</b>
				<b>&lt;</b>
				<i> type-id</i>
				<b> &gt;</b>
				<b>(</b>
				<i>expression </i>
				<b>)</b>
				<br />  type-id :必须是指针或者引用<br />  expression:必须是指针或者一个左值<br />基本上是用来做 子对象间的转换<br />1.基本的用法<br /><pre class="code">class B { ... };
class C : public B { ... };
class D : public C { ... };

void f(D* pd)
{
   C* pc = dynamic_cast&lt;C*&gt;(pd);   // ok: C is a direct base class
                                 // pc points to C subobject of pd 

   B* pb = dynamic_cast&lt;B*&gt;(pd);   // ok: B is an indirect base class
                                 // pb points to B subobject of pd 
   ...
}</pre><p>This type of conversion is called an "upcast" because it moves a pointer up a class hierarchy, from a derived class to a class it is derived from. An upcast is an implicit conversion.</p><p>If <i>type-id</i> is void*, a run-time check is made to determine the actual type of <i>expression</i>. The result is a pointer to the complete object pointed to by <i>expression</i>. For example:</p><pre class="code">class A { ... };

class B { ... };

void f()
{
   A* pa = new A;
   B* pb = new B;
   void* pv = dynamic_cast&lt;void*&gt;(pa);
   // pv now points to an object of type A
   ...
   pv = dynamic_cast&lt;void*&gt;(pb);
   // pv now points to an object of type B
}</pre><p>If <i>type-id</i> is not void*, a run-time check is made to see if the object pointed to by <i>expression</i> can be converted to the type pointed to by <i>type-id</i>.</p><p>If the type of <i>expression</i> is a base class of the type of <i>type-id</i>, a run-time check is made to see if <i>expression</i> actually points to a complete object of the type of <i>type-id</i>. If this is true, the result is a pointer to a complete object of the type of <i>type-id</i>. For example:</p><pre class="code">class B { ... };
class D : public B { ... };

void f()
{
   B* pb = new D;                     // unclear but ok
   B* pb2 = new B;

   D* pd = dynamic_cast&lt;D*&gt;(pb);      // ok: pb actually points to a D
   ...
   D* pd2 = dynamic_cast&lt;D*&gt;(pb2);   // pb2 points to a B not a D
                                    // cast was bad so pd2 == NULL
   ...
}</pre><p>This type of conversion is called a "downcast" because it moves a pointer down a class hierarchy, from a given class to a class derived from it.<br />小结：<br />  a     实际指向对象 和   b 目标对象,  b 是a 的 基类（子对象），或者是2者 同级转换才成功<br />否则 目标为NULL;也就是说不能向下转<br /><br /><br /><br />2   多重非虚的继承模式<br /><br /></p><p class="label"><b>Class Hierarchy Showing Multiple Inheritance</b></p><p class="fig"><img alt="" src="ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vclang/html/vc39011.gif" border="0" /></p><p>A pointer to an object of type <code class="ce">D</code> can be safely cast to <code class="ce">B</code> or <code class="ce">C</code>. However, if <code class="ce">D</code> is cast to point to an <code class="ce">A</code> object, which instance of <code class="ce">A</code> would result? This would result in an ambiguous casting error. To get around this problem, you can perform two unambiguous casts. For example:</p><pre class="code">void f()
{
   D* pd = new D;
   A* pa = dynamic_cast&lt;A*&gt;(pd);      // error: ambiguous
   B* pb = dynamic_cast&lt;B*&gt;(pd);      // first cast to B
   A* pa2 = dynamic_cast&lt;A*&gt;(pb);   // ok: unambiguous
}</pre><p>Further ambiguities can be introduced when you use virtual base classes. Consider the class hierarchy shown in the following figure.</p><p>    也就是说在2意性下会失败<br />3.子对象间的转换<br /></p><p class="label"><b>Class Hierarchy Showing Duplicate Base Classes</b></p><p class="fig"><img alt="" src="ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vclang/html/vc39013.gif" border="0" /><br />    //pd 指向 e 对象<br />void f(D* pd)<br />{<br />   E* pe = dynamic_cast&lt;E*&gt;(pd);<br />   B* pb = pe;      // upcast, implicit conversion<br />   A* pa = pb;      // upcast, implicit conversion<br />}<br /><br />//pd 指向 e 对象<br />void f(D* pd)<br />{<br />   B* pb = dynamic_cast&lt;B*&gt;(pd);      // cross cast<br />   A* pa = pb;                  // upcast, implicit conversion<br />}<br /><br />  也就是  所谓 cross cast <br /><br />二  <b>typeid( </b><i>type-id</i><b> )     </b><b>typeid( </b><i>expression</i><b> )</b> <br />   此操作符返回个  const type_info &amp; <br />            expression 必须指向一个多态类型（带虚函数    ），并且要解引用<br /><br />#include &lt;iostream&gt;<br />#include &lt;typeinfo.h&gt;</p></dd>
		<dd>
				<p class="fig">class Base {<br />public:<br />   virtual void vvfunc() {}<br />};</p>
		</dd>
		<dd>
				<p class="fig">class Derived : public Base {};</p>
		</dd>
		<dd>
				<p class="fig">using namespace std;<br />int main()<br />{<br />   Derived* pd = new Derived;<br />   Base* pb = pd;<br />   cout &lt;&lt; typeid( pb ).name() &lt;&lt; endl;   //prints "class Base *"<br />   cout &lt;&lt; typeid( *pb ).name() &lt;&lt; endl;   //prints "class Derived"<br />   cout &lt;&lt; typeid( pd ).name() &lt;&lt; endl;   //prints "class Derived *"<br />   cout &lt;&lt; typeid( *pd ).name() &lt;&lt; endl;   //prints "class Derived"<br />   delete pd;<br />}<br />// compile with: /GR /EHsc<br /><br />在模版中使用<br />template &lt; typename T &gt; T max( T arg1, T arg2 ) {<br />   cout &lt;&lt; typeid( T ).name() &lt;&lt; "s compared." &lt;&lt; endl;<br />   return ( arg1 &gt; arg2 ? arg1 : arg2 );<br />}<br /><br /><br />            </p>
		</dd>
<img src ="http://www.cppblog.com/bloodsuck/aggbug/9360.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-07-04 10:23 <a href="http://www.cppblog.com/bloodsuck/archive/2006/07/04/9360.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个com组件的练习</title><link>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9244.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Fri, 30 Jun 2006 09:23:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9244.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/9244.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9244.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/9244.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/9244.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: //				 {7B55D765-68A6-404e-99E2-CA9ABC389A27}																								static				 				const				  GUID IID_IUnknown9				=				 																								{ 						0x7b55d765...&nbsp;&nbsp;<a href='http://www.cppblog.com/bloodsuck/archive/2006/06/30/9244.html'>阅读全文</a><img src ="http://www.cppblog.com/bloodsuck/aggbug/9244.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-06-30 17:23 <a href="http://www.cppblog.com/bloodsuck/archive/2006/06/30/9244.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC中 windows object 和 C++ object</title><link>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9222.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Fri, 30 Jun 2006 03:33:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9222.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/9222.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/06/30/9222.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/9222.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/9222.html</trackback:ping><description><![CDATA[
		<p class="label">
				<b>The Problem</b>
		</p>
		<p>Windows objects are normally represented by <b>HANDLE</b>s. The MFC classes wrap Windows object handles with C++ objects. The handle wrapping functions of the MFC class library provide a way to find the C++ object that is wrapping the Windows object with a particular handle. There are times when a Windows object does not have a C++ wrapper object, however, and at these times a temporary object is created to act as the C++ wrapper.<br /></p>
		<p>mfc 映射的 windows object ----&gt;c++ wrapper<br />以下使用 mfc 的函数 如：fromhandle, getdlgitem,都会返回temporary 和 pemanent  c++ wrapper object<br /> 注意：<br />     零时的 对象 会被在空闲时(<strong>OnIdle()函数)</strong>被删除，不能存下在下次消息处理中 使用<br />The default <b>OnIdle</b> processing in <b>CWinThread</b> automatically calls <b>DeleteTempMap</b> for each class that supports temporary handle maps<br />////////////////////////////////////////////////////////////<br />The Windows objects that use handle maps are: 
</p>
		<ul type="disc">
				<li>
						<b>HWND</b> (<b>CWnd</b> and <b>CWnd</b>-derived classes) 
</li>
				<li>
						<b>HDC</b> (<b>CDC</b> and <b>CDC</b>-derived classes) 
</li>
				<li>
						<b>HMENU</b> (<b>CMenu</b>) 
</li>
				<li>
						<b>HPEN</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HBRUSH</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HFONT</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HBITMAP</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HPALETTE</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HRGN</b> (<b>CGdiObject</b>) 
</li>
				<li>
						<b>HIMAGELIST</b> (<b>CImageList</b>) 
</li>
				<li>
						<b>SOCKET</b> (<b>CSocket</b>) </li>
		</ul>
		<p>///////////////////////////////////////////////</p>
		<p>Given a handle to any of these objects, you can find the MFC object that wraps the handle by calling the static member function <b>FromHandle</b>. For example, given an <b>HWND</b> called <i>hWnd</i>:</p>
		<pre class="code">CWnd::FromHandle(hWnd)</pre>
		<p>will return a pointer to the <b>CWnd</b> that wraps the <i>hWnd</i>. If that <i>hWnd</i> does not have a specific wrapper object, then a temporary <b>CWnd</b> is created to wrap the <b>hWnd</b>. This makes it possible to get a valid C++ object from any handle.</p>
		<p>Once you have a wrapper object, you can get to its handle through a public member variable. In the case of a <b>CWnd</b>, <i>m_hWnd</i> contains the <b>HWND</b> for that object.</p>
		<p class="label">
				<b>Attaching Handles to MFC Objects</b>
		</p>
		<p>Given a newly created handle-wrapper object and a handle to a Windows object, you can associate the two by calling <b>Attach</b>. For example:</p>
		<pre class="code">CWnd myWnd;
myWnd.Attach(hWnd);<br />  ////mywnd 析构时会调用 destroywindow ,连同 hwnd 一起销毁<br /><br /><br /><br /><br /></pre>
		<p>This makes an entry in the permanent map associating <i>myWnd</i> and <i>hWnd</i>. <br />Calling <b>CWnd::FromHandle</b>(<i>hWnd</i>) will now return a pointer to <i>myWnd</i>. <br />When <i>myWnd</i> is deleted, the destructor will automatically destroy the hWnd by calling the Windows <b>DestroyWindow</b> function. If this is not desired, the <i>hWnd</i> must be detached from <i>myWnd</i> before the <i>myWnd</i> object is destroyed (normally when leaving the scope at which <i>myWnd</i> was defined). The <b>Detach</b> member function does this.</p>
		<pre class="code">myWnd.Detach();</pre>
		<p class="label">
				<b>More About Temporary Objects</b>
		</p>
		<p>Temporary objects are created whenever <b>FromHandle</b> is given a handle that does not already have a wrapper object. These temporary objects are detached from their handle and deleted by the <b>DeleteTempMap</b> functions. The default <b>OnIdle</b> processing in <b>CWinThread</b> automatically calls <b>DeleteTempMap</b> for each class that supports temporary handle maps. This means that you cannot assume a pointer to a temporary object will be valid past the point of exit from the function where the pointer was obtained, as the temporary object will be deleted during the Windows message-loop idle time.</p>
		<p class="label">
				<b>很重要:<br />在多线程中传递 c++ wrapper object 是无效的(无论是 temporary 还是 permanent)<br />只能传递 windows handle, 换句话就是说， 线程 只能 访问 自己创建的c++ wrapper object<br /><br />Wrapper Objects and Multiple Threads</b>
		</p>
		<p>
				<font color="#ff0000">Both temporary and permanent objects are maintained on a per-thread basis. That is, one thread cannot access another threads C++ wrapper objects, regardless of whether it is temporary or permanent. As stated above, temporary objects are deleted when the thread which that temporary object belongs enters <b>OnIdle</b>.</font>
		</p>
		<p>
				<font color="#ff0000">To pass these objects from one thread to another, always send them as their native <b>HANDLE</b> type. Passing a C++ wrapper object from one thread to another will often result in unexpected results.</font>
		</p>
		<p>
				<font color="#ff0000">     </font>
		</p>
<img src ="http://www.cppblog.com/bloodsuck/aggbug/9222.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-06-30 11:33 <a href="http://www.cppblog.com/bloodsuck/archive/2006/06/30/9222.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL 乱学二（原创）</title><link>http://www.cppblog.com/bloodsuck/archive/2006/06/02/8084.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Fri, 02 Jun 2006 07:43:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/06/02/8084.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/8084.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/06/02/8084.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/8084.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/8084.html</trackback:ping><description><![CDATA[1.容器<br />   顺序: vector(类似动态增长数组）  deque （双端队列）  list（双头指针）<br />   关联:set  multiset(有重复）  map   multiset（有重复） ，自动排序（内部2叉树）<br />  特殊预定义容器：stack, queue ,prority queue<br />2.迭代器<br />      每种容器都提供了自己的迭代器，相同的操作界面，不同的内部实现，<br />   *,-&gt;,==,!=,++,--共同操作<br />     随机iterator : 支持 &gt;，&lt;:如：vector, deque,string<br />    双向iterator:不支持&gt;,&lt;:<br />   特殊预定义：<br />插入迭代器<br />          insert iterator:引起自动增长，非覆盖<br />             back_inserter(container)<br />             front_inserter(container)<br />           inserter(container,pos)//调用 container.insert()//每种容器都具有insert()//关联容器唯一<br /> 流迭代器<br />             istream_iterator<br />             ostream_iterator<br /> 逆向迭代器<br />容器中元素应满足：<br />     有拷贝构造，赋值运算符，析构能销毁<br />   顺序：默认构造应该可用<br />   关联：必须有排序准则<br />容器中是 值不是引用<br /><br />通用操作：<br />   containertype c;<br />  ct  c(c1);<br />  ct   c(begin,end);<br /> c.~ct();<br /> c.size(), c.max_size(),c.empty(),c1==c2;c1&lt;c2;c1.swap(c2); swap(c1,c2);c.begin();c.end();c.rbegin();c.rend();<br />c.inert(pos,elem);c.erase(begin,end),c.clear(),c.get_allocator<br /> <br />     3.vector <br />    动态增长数组,在队尾插入，删除效率高<br />注意 动态增长时 迭代器失效 内部可能要重配置<br />除了clear(),vector 不会自动缩小<br />vector 的迭代器 就是 元素的native指针,连续存储，迭代器是个random <br />空判断<br />       a.begin==a.end<br /><br />4.list <br />   迭代器是个双向的，非连续存储，而且是个环状链表在尾端是个未初始化节点<br />空判断<br />   a.begin==a.end;<br />clear  remove  unique(把相同元素移出，留一个)  insert<br />只能使用成员函数 sort，不能使用 算法 sort(他只接受random iterator)<br />5 .deque<br />动态增长的双端队列 ，但内部机制和vector 不一样 ，若干连续存储的集合<br />算法复杂度高，如排序时可将 其复制到 vector中，头/尾插入/删除效率高  ，<br />提供随机迭代器<br />6.stack (container adapter)<br />先进后出，不供迭代器， 不提供走访功能<br />7.queue(container adapter)<br />  先进先出，不提供迭代器，不提供走访功能<br />8.heap 辅助<br />   其内部为一个完全2叉树，插入时自动排序，一般为max_heap<br />   左右无序，某节点 i, 父节点 i/2,左子节点 2i，右子节点 2i+1；<br /> <pre class="syntax"><b>template&lt;class RandomAccessIterator&gt; inline</b><b>   void make_heap(</b><b>      RandomAccessIterator </b><i>First</i><b>,</b><b>      RandomAccessIterator </b><i>Last</i><b>   )</b><b>template&lt;class RandomAccessIterator&gt; inline</b><b>   void sort_heap(</b><b>      RandomAccessIterator </b><i>First</i><b>,</b><b>      RandomAccessIterator </b><i>Last</i><b>   )</b><b>template&lt;class RandomAccessIterator&gt; inline</b><b>   void push_heap(</b><b>      RandomAccessIterator </b><i>First</i><b>,</b><b>      RandomAccessIterator </b><i>Last</i><b>   )</b><b>template&lt;class RandomAccessIterator&gt; inline</b><b>   void pop_heap(</b><b>      RandomAccessIterator </b><i>First</i><b>,</b><b>      RandomAccessIterator </b><i>Last</i><b>   )</b></pre>         <br />             9.set,关联容器 ，底层以rb-tree 实现，其迭代器为个const iterator<br />   不能用迭代器来改变 元素值，缺省下以递增排序<img src ="http://www.cppblog.com/bloodsuck/aggbug/8084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-06-02 15:43 <a href="http://www.cppblog.com/bloodsuck/archive/2006/06/02/8084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>STL 乱学一（原创）</title><link>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7950.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Wed, 31 May 2006 08:53:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7950.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/7950.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7950.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/7950.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/7950.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1								template 				&lt;				typename T1,typename T2				&gt;																		 2																		class				 mypair :				public				 pair				&lt;				T1,T2				&gt;...&nbsp;&nbsp;<a href='http://www.cppblog.com/bloodsuck/archive/2006/05/31/7950.html'>阅读全文</a><img src ="http://www.cppblog.com/bloodsuck/aggbug/7950.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bloodsuck/" target="_blank">黄大仙</a> 2006-05-31 16:53 <a href="http://www.cppblog.com/bloodsuck/archive/2006/05/31/7950.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++书籍下（转载）</title><link>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7936.html</link><dc:creator>黄大仙</dc:creator><author>黄大仙</author><pubDate>Wed, 31 May 2006 05:36:00 GMT</pubDate><guid>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7936.html</guid><wfw:comment>http://www.cppblog.com/bloodsuck/comments/7936.html</wfw:comment><comments>http://www.cppblog.com/bloodsuck/archive/2006/05/31/7936.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bloodsuck/comments/commentRss/7936.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bloodsuck/services/trackbacks/7936.html</trackback:ping><description><![CDATA[
		<font face="Verdana"> 我在上篇中“盘点”了TCPL和D&amp;E以及入门教程、高效和健壮编程、模板和泛型编程等方面共十几本C++好书。冬去春来，让我们继续C++书籍精彩之旅J  </font>
		<p>
				<font face="Verdana">标准库  </font>
		</p>
		<p>
				<font face="Verdana">当我还在研究院工作时，与同院另外两家研究所合作开发过一个大型水利枢纽调度集成项目。我们三家软件系统之间都要相互通信。在调试通讯模块时，细心的客户（一名好学的系统管理员）发现对于同一通信规约的解释代码，我的不超过30行，而对方的则超过了150行且很难看懂。这位系统管理员很纳闷，我说大家编程风格和习惯不一样，我使用了标准库，而他使用了传统C编程风格以及他所习惯的另外一些技术。  </font>
		</p>
		<p>
				<font face="Verdana">别误会！我绝无贬低这位合作伙伴的意思。事实上，我对那些真正有着深厚的C编程功力的程序员常常怀有钦佩之心。毕竟，C++能有今天的成功在很大程度上缘于它深深地植根于C。作为一名C++程序员，倘若不熟悉C++中的C，我往往会认为他的基本功是不扎实的，他的技术底气是不足的。  </font>
		</p>
		<p>
				<font face="Verdana">不过话又说回来，C++是一种多范型（paradigm）编程语言，具体采用哪种编程风格，专业程序员应该知道视具体情况而定。作为一名经常需要在现场做即兴开发的项目负责人，为了短平快地解决当务之急，我习惯尽量采用现有的库（和组件）。效率（以及强健性）久经验证的C++标准库已经摆在那儿了，何乐而不用呢？  </font>
		</p>
		<p>
				<font face="Verdana">Nicolai M. Josuttis, The C++ Standard Library: A Tutorial and Reference <br />《C++标准程序库：自修教程与参考手册》，华中科技大学出版社 </font>
		</p>
		<p>
				<font face="Verdana">这是一本百科全书式的C++标准库著作，是一本需要一再查阅的参考大全。它在完备性、细致性以及精确性方面都是无与伦比的。本书详细介绍了每一标准库组件的规格和用法，内容涵盖包括流和本地化在内的整个标准库而不仅仅是STL。正如本书副标题所示，它首先适合作为教程阅读，尔后又可用作参考手册。 </font>
		</p>
		<p>
				<font face="Verdana">浅显易懂的写作风格使得这本书非常易读。如果你希望学习标准库的用法并尽可能地发挥其潜能，那你必须拥有这本书。正如网络上所言，这本书不仅仅应该摆在你的书橱中，更应该放到你的电脑桌上。我向每一位职业C++程序员强烈推荐。 </font>
		</p>
		<p>
				<font face="Verdana">Angelika Langer, Klaus Kreft, Standard C++ IOStreams and Locales: Advanced Programmer's Guide and Reference <br />《标准C++输入输出流与本地化》，人民邮电出版社 </font>
		</p>
		<p>
				<font face="Verdana">C++标准库由STL、流和本地化三部分构成。关于STL的书市面上已经有不少，但罕见流和本地化方面的专著。本书是这两个领域中最优秀的一本，迄今为止没有任何一本书比这一本更全面详尽地讨论了流和本地化。如果你不满足于停留在“会用”流库的层面，千万不要错过它。 </font>
		</p>
		<p>
				<font face="Verdana">2001年夏天，我草草翻阅过这本书的中文版，从内容到包装都给我留下了比较深刻的印象 — 不过负面的居多一些。2003年秋天，无意中得知某网络书店正以超低价格甩卖这本书的中译本，情不自禁，一阵唏嘘。 </font>
		</p>
		<p>
				<font face="Verdana">Scott Meyers, Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library <br />《Effective STL（影印版）》，中国电力出版社 </font>
		</p>
		<p>
				<font face="Verdana">读完Scott 的《Effective C++》和《More Effective C++》的中译本之后，我一直期待这本书的中文版。我从潘爱民先生的个人主页上了解到，他和他的合作伙伴似乎早已完成了这本书的翻译工作，可惜至今市面上仍不得见。幸运的是，我们可以看到它的原版。 </font>
		</p>
		<p>
				<font face="Verdana">本书是使用STL的程序员必读之作。在这本书中，Scott向我们讲述STL容器和算法的工作机制以及如何以最佳方式使用它们。和Scott的其他作品一样，这本书的写作风格清晰、精确，具有极佳的可读性。看过这本书以后，我想你也许会和我以及其他C++程序员一样产生这样的想法：Scott什么时候会写出一本“More Effective STL”？ </font>
		</p>
		<p>
				<font face="Verdana">关于STL，我还提醒你留心Matthew H. Austern的《Generic Programming and the STL: Using and Extending the C++ Standard Template Library》（《泛型编程与STL》，中国电力出版社）。这本书散发着浓厚的学院气息。Andrew Koenig和Barbara Moo在《Accelerated C++: Practical Programming by Example》一书末尾郑重推荐另外两本进阶好书（除了他们自己的《Ruminations on C++》外），其中一本是TCPL，另外一本就是本书！ </font>
		</p>
		<p>
				<font face="Verdana">网络编程 </font>
		</p>
		<p>
				<font face="Verdana">在网络编程时代，C++应该扮演着怎样的角色，让ACE（Adaptive Communications Environment）来告诉你。 </font>
		</p>
		<p>
				<font face="Verdana">Douglas C. Schmidt, Stephen D. Huston, C++ Network Programming, Volume 1: Mastering Complexity with ACE and Patterns <br />Douglas C. Schmidt, Stephen D. Huston, C++ Network Programming, Volume 2: Systematic Reuse with ACE and Frameworks <br />《C++网络编程，卷1：运用ACE和模式消除复杂性》，华中科技大学出版社 <br />《C++网络编程，卷2：基于 ACE 和框架的系统化复用》，电子工业出版社 </font>
		</p>
		<p>
				<font face="Verdana">采用C++进行企业级网络编程，目前ACE（以及这两本书）是一个值得考虑的选择。ACE是一个面向对象、跨平台、开放源码的网络编程框架，目标在于构建高性能网络应用和中间件。Douglas是ACE的创始人，Stephen则已为ACE提供了数年的技术支持和顾问服务，两位都是ACE社群（是的，ACE的影响和实际应用的程度已经形成了一个社群）的专家。 </font>
		</p>
		<p>
				<font face="Verdana">ACE并不单单被大学和研究所追捧，它已经被成功地应用于世界上成千上万个商业应用中。在电信、宇航、医药和财经领域的网络系统中，ACE已经并继续发挥着重要的作用。如果你准备开发高性能通讯系统，你应该考虑考虑这一汇集世界顶尖专家智慧的成果。 </font>
		</p>
		<p>
				<font face="Verdana">除了使用C++面向对象设计技术和模板等高级语言特性外，ACE还运用了大量的模式。《C++网络编程》卷1和卷2并不仅仅教你关于ACE的方方面面，它还会教给你模式和通用框架设计等高级技术等。所以，作为一名中、高级C++程序员，即使你很少进行正儿八经的C++网络程序设计，阅读这两本书同样可以从中受益。 </font>
		</p>
		<p>
				<font face="Verdana">是的，并非所有网络应用都要使用Web服务器（以及其他应用服务器）和重量级组件模型，换个思路，它们或许也可以从轻量级的ACE组件中获益。 </font>
		</p>
		<p>
				<font face="Verdana">杂项 </font>
		</p>
		<p>
				<font face="Verdana">以下这几本书之所以被列入“杂项”单元，只是因为我没有考虑出更合适的归类方法，它们和上面的书籍一样，值得一读。 </font>
		</p>
		<p>
				<font face="Verdana">Bruce Eckel, Thinking in C++, Volume 1: Introduction to Standard C++ (2nd Edition) <br />Bruce Eckel, Thinking in C++, Volume 2: Practical Programming (Second Edition) <br />《C++编程思想（第2版）第1卷：标准C++导引》，机械工业出版社 <br />《C++编程思想（英文版 第2版）》，机械工业出版社 </font>
		</p>
		<p>
				<font face="Verdana">《Thinking in C++》的第1版于1996年荣获“软件研发”杂志评选的图书震撼大奖。最新推出的第2版对内容进行了大幅改写和调整，以反映C++标准化带来的影响以及近几年面向对象领域最新研究和实践成果。“输入输入流”、“多重继承”、“异常处理”和“运行时类型识别”等高级主题连同C++标准化以后增加的一些内容则被放入第二卷中。Bruce是一名经验丰富的C++讲师和顾问，其培训和写作经验都是世界一流水准，他的作品比那些“玩票”的技术人员写的东西更能吸引读者。事实上，在同类图书中，对于大多数读者而言，这本书的可读性要超过TCPL和《C++ Primer》。顺带一提，访问作者的站点，你可以先睹第二卷的风采。 </font>
		</p>
		<p>
				<font face="Verdana">Andrew Koenig, Barbara E. Moo, Ruminations on C++: A Decade of Programming Insight and Experience <br />《C++沉思录》，人民邮电出版社 </font>
		</p>
		<p>
				<font face="Verdana">Andrew是世界上屈指可数的C++专家。这是一本关于C++编程思想和程序设计技术而非语言细节的著作。如果你已经具有一定的基础，这本书将教你在进行C++编程时应该怎样思考，应该如何表达解决方案。整本书技术表达透彻，文字通俗易懂。Bjarne这样评价这本书：本书遍布“C++是什么、C++能够做什么”的真知灼见。 </font>
		</p>
		<p>
				<font face="Verdana">Stanley B. Lippman, Inside The C++ Object Model <br />《深度探索C++对象模型》，华中科技大学出版社 <br />《深度探索C++对象模型（影印版）》，中国电力出版社 </font>
		</p>
		<p>
				<font face="Verdana">从编译器的角度观察C++可以使你知其然并知其所以然。本书探讨了大量的C++面向对象程序设计的底层运作机制，包括构造函数、函数、临时对象、继承、虚拟、模板的实例化、异常处理、运行期类型识别等，另外还介绍了一些在实现C++对象模型过程中做出的权衡折衷。喜欢刨根问底的C++程序员不要错过这本书。 </font>
		</p>
		<p>
				<font face="Verdana">Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Design Patterns: Elements of Reusable Object-Oriented software <br />《设计模式：可复用面向对象软件的基础》，机械工业出版社 <br />《设计模式：可复用面向对象软件的基础（英文版）》，机械工业出版社 </font>
		</p>
		<p>
				<font face="Verdana">设计可复用的面向对象的软件，你需要掌握设计模式。本书并非专为C++程序员而写，但它采用了C++（以及Smalltalk）作为主要示例语言，C++程序员尤其易于从中受益。四位作者都是国际公认的面向对象软件领域专家，他们将面向对象软件的设计经验作为设计模式详细记录下来。这本书影响是如此深远，以至于四位作者以及本书都被昵称为GoF（Gang of Four）。本书学院气息浓厚，行文风格严谨简洁，虽然它不如某些讲解模式的书籍易读，但真正要精准地理解设计模式，本书是终极权威。学习设计模式，这本书需要一而再、再而三的咀嚼。顺带一句：请将设计模式化作开拓思维的钥匙，切莫成为封闭思维的枷锁。 </font>
		</p>
		<p>
				<font face="Verdana">还有一些C++好书值得一读，恕此处无法一一列出。例如John Lakos的著作《Large-Scale C++ Software Design》（《大规模C++程序设计》，中国电力出版社）和侯捷先生的《STL 源码剖析》（华中科技大学出版社）等。 </font>
		</p>
		<p>
				<font face="Verdana">《STL 源码剖析》是一本很有特色的书，但我认为它还可以更好。我个人期待侯捷先生自第一版发行以来经过对模板技术的沉淀和再思考之后，再写一本剖析得更深入、更透彻并且更全面的“第二版”。遗憾的是，侯捷先生在完成《C++ Templates: The Complete Guide》一书的翻译后似乎决定暂时告别模板、泛型编程和STL领域。 </font>
		</p>
		<p>
				<font face="Verdana">2004年3月31日补充：我目前最常查阅的两本参考书是《C++标准程序库》和《STL源码剖析》。当然了，这与我年内的写作计划有很大的关系。 </font>
		</p>
		<p>
				<font face="Verdana">使用C++成功开发大规模软件系统，不仅需要很好地理解大多数C++书籍中讲述的逻辑设计问题，更需要掌握《大规模C++程序设计》中讲述的