﻿<?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++博客-重剑无锋，大巧不工-随笔分类-面试笔试</title><link>http://www.cppblog.com/lai3d/category/2183.html</link><description>&lt;span style="color: #000000;"&gt;常有人询问，编程需要天赋吗？啊，任何事情走往极致，都需要天赋。任何一个软件产品的极致成功，都需要创意天赋、编程天赋、管理天赋、行销天赋……。然而，只需用心模仿，再加一点匠心独具，任何人都能够把编程路走得稳当顺遂。能读千赋则善赋，能观千剑则晓剑，巧者不过习者之门也。你把名家源码融为己用，别人也会赞叹一声“你有编程天赋”。子曾经曰过：编程无他，唯手熟尔！&lt;/span&gt;</description><language>zh-cn</language><lastBuildDate>Thu, 28 Apr 2011 04:22:24 GMT</lastBuildDate><pubDate>Thu, 28 Apr 2011 04:22:24 GMT</pubDate><ttl>60</ttl><item><title>招聘UI帝，客户端逻辑，熟悉OGRE/CEGUI/Lua优先，薪水给力</title><link>http://www.cppblog.com/lai3d/archive/2011/04/28/145193.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Thu, 28 Apr 2011 03:00:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2011/04/28/145193.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/145193.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2011/04/28/145193.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/145193.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/145193.html</trackback:ping><description><![CDATA[招聘UI帝，客户端逻辑，熟悉OGRE/CEGUI/Lua优先，薪水给力 <br><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><span style="LINE-HEIGHT: 20px; FONT-FAMILY: verdana, Arial, helvetica, sans-seriff; COLOR: rgb(75,75,75); FONT-SIZE: 13px" class=Apple-style-span>项目为MMORPG 2.5D，使用OGRE引擎，公司在上海长宁区，有意者发到 lai3d at 163.com<br><br>IE 9 &amp; Chrome都写不了cppblog了，blog程序改升级了吧？</span></span>
<img src ="http://www.cppblog.com/lai3d/aggbug/145193.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2011-04-28 11:00 <a href="http://www.cppblog.com/lai3d/archive/2011/04/28/145193.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[职业经历]职业生涯步步高－－一位资深经理人的职业生涯感悟</title><link>http://www.cppblog.com/lai3d/archive/2009/05/31/86240.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Sun, 31 May 2009 03:24:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2009/05/31/86240.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/86240.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2009/05/31/86240.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/86240.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/86240.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在担任公司高管的几年间，我面试过数以百计的各个层面的员工，其中最让我感到遗憾的一个现象就是很多人有着非常好的素质，甚至有的还是名校的毕业生，因为不懂得去规划自己的职业，在工作多年后，依然拿着微薄的薪水，为了一份好一点的工作而奔波。很多这样的人，他们只要稍微修正一下自己的职业方向，就能够在职业发展上走得更从容。&nbsp;&nbsp;<a href='http://www.cppblog.com/lai3d/archive/2009/05/31/86240.html'>阅读全文</a><img src ="http://www.cppblog.com/lai3d/aggbug/86240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2009-05-31 11:24 <a href="http://www.cppblog.com/lai3d/archive/2009/05/31/86240.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>强烈建议C++博客增加tags功能</title><link>http://www.cppblog.com/lai3d/archive/2009/04/14/79924.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Tue, 14 Apr 2009 09:57:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2009/04/14/79924.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/79924.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2009/04/14/79924.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/79924.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/79924.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 现在blog没有tags简直就是从火星来的了，老大们说是不？<br>主要就是有这个需要，倒不是我追赶时髦，我还没那么肤浅吧？满足需要就好。&nbsp;&nbsp;<a href='http://www.cppblog.com/lai3d/archive/2009/04/14/79924.html'>阅读全文</a><img src ="http://www.cppblog.com/lai3d/aggbug/79924.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2009-04-14 17:57 <a href="http://www.cppblog.com/lai3d/archive/2009/04/14/79924.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>做笔试题增长功力（3）--华为</title><link>http://www.cppblog.com/lai3d/archive/2007/10/18/34505.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Wed, 17 Oct 2007 16:58:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2007/10/18/34505.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/34505.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2007/10/18/34505.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/34505.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/34505.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 华为笔试面试&nbsp;&nbsp;<a href='http://www.cppblog.com/lai3d/archive/2007/10/18/34505.html'>阅读全文</a><img src ="http://www.cppblog.com/lai3d/aggbug/34505.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2007-10-18 00:58 <a href="http://www.cppblog.com/lai3d/archive/2007/10/18/34505.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>做笔试题增长功力（1）-- 盛大</title><link>http://www.cppblog.com/lai3d/archive/2007/10/17/34401.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Tue, 16 Oct 2007 21:52:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2007/10/17/34401.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/34401.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2007/10/17/34401.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/34401.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/34401.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 盛大笔试面试&nbsp;&nbsp;<a href='http://www.cppblog.com/lai3d/archive/2007/10/17/34401.html'>阅读全文</a><img src ="http://www.cppblog.com/lai3d/aggbug/34401.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2007-10-17 05:52 <a href="http://www.cppblog.com/lai3d/archive/2007/10/17/34401.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>做笔试题增长功力（1）-- Ubisoft</title><link>http://www.cppblog.com/lai3d/archive/2007/08/29/31085.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Wed, 29 Aug 2007 01:02:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2007/08/29/31085.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/31085.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2007/08/29/31085.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/31085.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/31085.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/lai3d/archive/2007/08/29/31085.html'>阅读全文</a><img src ="http://www.cppblog.com/lai3d/aggbug/31085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2007-08-29 09:02 <a href="http://www.cppblog.com/lai3d/archive/2007/08/29/31085.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于String类的笔试题及解答</title><link>http://www.cppblog.com/lai3d/archive/2006/07/13/9822.html</link><dc:creator>七星重剑</dc:creator><author>七星重剑</author><pubDate>Thu, 13 Jul 2006 14:21:00 GMT</pubDate><guid>http://www.cppblog.com/lai3d/archive/2006/07/13/9822.html</guid><wfw:comment>http://www.cppblog.com/lai3d/comments/9822.html</wfw:comment><comments>http://www.cppblog.com/lai3d/archive/2006/07/13/9822.html#Feedback</comments><slash:comments>15</slash:comments><wfw:commentRss>http://www.cppblog.com/lai3d/comments/commentRss/9822.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lai3d/services/trackbacks/9822.html</trackback:ping><description><![CDATA[
		<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<span style="color: rgb(0, 128, 128);">/* 这类看着熟悉不?林锐大哥书上的,嘿嘿,好多公司都考啊! 大家给挑挑错误,改进一下.顺便解答一下我的疑问 */<br /> 1</span> <span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> String<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">:<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    String(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">str </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> NULL);    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 普通构造函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    String(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> String </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">other);        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 拷贝构造函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">~</span><span style="color: rgb(0, 0, 0);">String(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">);                        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 析构函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    String </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> String </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">other);    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 赋值函数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);">()(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">:<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">m_data;                </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 用于保存字符串</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">};<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">String::</span><span style="color: rgb(0, 0, 0);">~</span><span style="color: rgb(0, 0, 0);">String(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">    delete[] m_data;<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">String::String(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> str)<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(NULL </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> str)<br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 不能让新对象的m_data为NULL</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        m_data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">m_data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">\0</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">    }    <br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> length </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> strlen(str);<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">        m_data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">[length </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">        strcpy(m_data, str);<br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);">String::String(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> String</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);"> other) </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 因为是新构造一个对象，所以不需要像operator=一样判断自赋值及释放原来的内存 </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> length </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> strlen(other.m_data);<br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 0, 0);">    m_data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">[length </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">    strcpy(m_data, other.m_data);<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);">String</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);"> String::</span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> String</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);"> other)<br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 判断自赋值</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">other)<br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> 释放原来的内存</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    delete [] m_data;<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> length </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> strlen(other.m_data); </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 虽然m_data是private,但因为是在String的成员函数里，故没问题 </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">51</span> <span style="color: rgb(0, 0, 0);">    m_data </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">[length </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">52</span> <span style="color: rgb(0, 0, 0);">    strcpy(m_data, other.m_data);<br /></span><span style="color: rgb(0, 128, 128);">53</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">54</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">55</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">56</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">57</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">58</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> String::</span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);">()() </span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">59</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">60</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">)m_data;<br /></span><span style="color: rgb(0, 128, 128);">61</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">62</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">63</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> _tmain(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> argc, _TCHAR</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> argv[])<br /></span><span style="color: rgb(0, 128, 128);">64</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">65</span> <span style="color: rgb(0, 0, 0);">    String str(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">hello</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">66</span> <span style="color: rgb(0, 0, 0);">    String str1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> str; </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 这儿调用的是copy constructor,非 operator=, why? </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">67</span> <span style="color: rgb(0, 0, 0);">    printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%s\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, str1);<br /></span><span style="color: rgb(0, 128, 128);">68</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">69</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> str2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> str();<br /></span><span style="color: rgb(0, 128, 128);">70</span> <span style="color: rgb(0, 0, 0);">    printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%s\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, str2);<br /></span><span style="color: rgb(0, 128, 128);">71</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">72</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">73</span> <span style="color: rgb(0, 0, 0);">}</span></div>
<img src ="http://www.cppblog.com/lai3d/aggbug/9822.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lai3d/" target="_blank">七星重剑</a> 2006-07-13 22:21 <a href="http://www.cppblog.com/lai3d/archive/2006/07/13/9822.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>