??xml version="1.0" encoding="utf-8" standalone="yes"?>麻豆成人小视频,色8久久精品久久久久久蜜,亚洲激情中文http://www.aygfsteel.com/vagasnail/category/42600.htmld双Ӏ看说、写E序都是我所爱?/description>zh-cnSat, 12 Jun 2010 21:19:21 GMTSat, 12 Jun 2010 21:19:21 GMT60CRichEdit的中文字体问?/title><link>http://www.aygfsteel.com/vagasnail/articles/317636.html</link><dc:creator>vagasnail</dc:creator><author>vagasnail</author><pubDate>Wed, 07 Apr 2010 06:20:00 GMT</pubDate><guid>http://www.aygfsteel.com/vagasnail/articles/317636.html</guid><wfw:comment>http://www.aygfsteel.com/vagasnail/comments/317636.html</wfw:comment><comments>http://www.aygfsteel.com/vagasnail/articles/317636.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/vagasnail/comments/commentRss/317636.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/vagasnail/services/trackbacks/317636.html</trackback:ping><description><![CDATA[ <p>记录一下困扰我很多天的Q关于CRichEdit的问题:当双L开一个文档时Q中文字体在昄时会大一个字P真的不知道是Z么,现在也不知道是ؓ什么,但是我一个一个函数的试终于得C如下的结论:悲剧啊!</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"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000"> pContext )<br /><img id="Codehighlighter1_82_541_Open_Image" onclick="this.style.display='none'; Codehighlighter1_82_541_Open_Text.style.display='none'; Codehighlighter1_82_541_Closed_Image.style.display='inline'; Codehighlighter1_82_541_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_82_541_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_82_541_Closed_Text.style.display='none'; Codehighlighter1_82_541_Open_Image.style.display='inline'; Codehighlighter1_82_541_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span> <span id="Codehighlighter1_82_541_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.aygfsteel.com/images/dot.gif" /> </span> <span id="Codehighlighter1_82_541_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> 不要调用q个函数Q这个函数默认通过 pContext 创徏了一个 CView<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000"> 可以通过重写q个函数Q来改变H体的主客户区的昄?/span> <span style="COLOR: #008000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000"> success </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> m_wndSplitter.CreateStatic(</span> <span style="COLOR: #0000ff">this</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 /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> success </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> m_wndSplitter.CreateView(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  RUNTIME_CLASS(CMyXmlBoxView), <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  CSize(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, (</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">)(height </span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">)), <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  pContext);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> success </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> m_wndSplitter.CreateView(</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">, <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  RUNTIME_CLASS(COutputView), <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  CSize(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, (</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">)(height </span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">)), <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />  pContext);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 竟然在这里就可以避开Q双L开文档的函数调用序列,到底是ؓ什么呢Q?br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 鬼才晓得Q记得就可以了,在MainFrame的OnCreateClient中调用设|文本和D落<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 格式可以免于使字体诡异的扩大一个字P对底层我们很难了解,也是我讨?br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> MFC的原因了?/span><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> ((CMyXmlBoxView</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">)m_wndSplitter.GetPane(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">, </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">))</span> <span style="COLOR: #000000">-></span> <span style="COLOR: #000000">SetEditFormat();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000"> success;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <br /> </span> <span style="COLOR: #008000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> </div> <br />不要问我Z么?我也不知道?img src ="http://www.aygfsteel.com/vagasnail/aggbug/317636.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/vagasnail/" target="_blank">vagasnail</a> 2010-04-07 14:20 <a href="http://www.aygfsteel.com/vagasnail/articles/317636.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>最q的一些小心得http://www.aygfsteel.com/vagasnail/articles/317317.htmlvagasnailvagasnailFri, 02 Apr 2010 07:49:00 GMThttp://www.aygfsteel.com/vagasnail/articles/317317.htmlhttp://www.aygfsteel.com/vagasnail/comments/317317.htmlhttp://www.aygfsteel.com/vagasnail/articles/317317.html#Feedback0http://www.aygfsteel.com/vagasnail/comments/commentRss/317317.htmlhttp://www.aygfsteel.com/vagasnail/services/trackbacks/317317.html2. 记得在构造程序的时候,千万不要想着优化Q要{到当前模块Q甚x整个E序完成后再考虑优化问题?
3. 写程序的时候,请先写好注释Q再写实现的代码Q这样会更有思\?
4. 在开始写E序的时候,要先在脑子里惛_Q先在纸上或者电脑上得出大概的实现思\Q而不是一上手开始盲目的~码Q这样只会浪Ҏ_而且使脑子؜乱。在惛_具体而大致完整的解决思\后才可以开始编码?
5. i++, ++i
 W一个是在表辑ּ之后求|包括复合表达?如逗号表达? W二个是在表辑ּ之前求|包括复合表达?img src ="http://www.aygfsteel.com/vagasnail/aggbug/317317.html" width = "1" height = "1" />

vagasnail 2010-04-02 15:49 发表评论
]]>
A star法弱弱的小l?/title><link>http://www.aygfsteel.com/vagasnail/articles/307937.html</link><dc:creator>vagasnail</dc:creator><author>vagasnail</author><pubDate>Thu, 31 Dec 2009 09:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/vagasnail/articles/307937.html</guid><wfw:comment>http://www.aygfsteel.com/vagasnail/comments/307937.html</wfw:comment><comments>http://www.aygfsteel.com/vagasnail/articles/307937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/vagasnail/comments/commentRss/307937.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/vagasnail/services/trackbacks/307937.html</trackback:ping><description><![CDATA[ <p>搞了N个小Ӟl于杯具的把A*法写出来了Q这里只能弱q结一下:<br />A*法是一U启发式法Q?br />xơP代都q行启发式思考,判断F|<br />我们l护两个表,我这只用单的数组实现?br />OPEN表和CLOSE?br />OPEN表存储我们待搜烦的节?br />CLOSE表存储已l搜索好的节点,q些节点都是每次启发时F值最的?br />A为其?br />B为终?/p> <p>F = H + G<br />G = 从v点AQ沿着产生的\径,Ud到网g指定Ҏ的移动耗费。G = 距离(A) * 偏移?<br />H = 从网g那个ҎUd到终点B的预估移动耗费。这l常被称为启发式的,<br />    可能会让你有点迷惑。这样叫的原因是因ؓ它只是个猜测?br />    我们没办法事先知道\径的长度Q因\上可能存在各U障?墙,_{等)?br />    虽然本文只提供了一U计H的方法,但是你可以在|上扑ֈ很多其他的方法?br />    H = (列距?B) + 行距?B)) * 偏移?<br />我们选定上一ơ添加到CLOSE表的节点为当前节炏V?br />然后依次判断当前节点的四个或八个方向的节炏V如果这些节Ҏ障碍Q或者已l在CLOSE表中Q?br />则不予考虑Q否则将q些节点的父节点设ؓ当前节点Q这些节点如果也没有在OPEN表中Q?br />则加入OPEN表,如果q些节点~号已经出现在OPEN表中Q则判断他们的G|G值小的留下,G值大的扔掉?br />如果Gg相同Q保留后出现的?br />我们每次把OPEN表F值最的节点删去加入到CLOSE表中?br />但是如果存在两个节点的F值相同呢Q随机选一个?br />如此反复Q直到我们将B点加入CLOSE表?br />如何得到我们的\径呢Q从B点依靠父节点向上遍历p了?/p> <p>注意一炏V我们要保持OPEN表的有序对了,昄我们q里是通过F值来l持OPEN表的ơ序?br />而且每次d新的节点到OPEN表时都要排序。当然这里是用降序,q样对于数组来说更好操作?br /><br />感谢Q网上朋友提供的详细的资料?br /></p> <img src ="http://www.aygfsteel.com/vagasnail/aggbug/307937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/vagasnail/" target="_blank">vagasnail</a> 2009-12-31 17:21 <a href="http://www.aygfsteel.com/vagasnail/articles/307937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CSDN中关于C++学习的讨?/title><link>http://www.aygfsteel.com/vagasnail/articles/301214.html</link><dc:creator>vagasnail</dc:creator><author>vagasnail</author><pubDate>Thu, 05 Nov 2009 01:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/vagasnail/articles/301214.html</guid><wfw:comment>http://www.aygfsteel.com/vagasnail/comments/301214.html</wfw:comment><comments>http://www.aygfsteel.com/vagasnail/articles/301214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/vagasnail/comments/commentRss/301214.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/vagasnail/services/trackbacks/301214.html</trackback:ping><description><![CDATA[ <p>  本文从CSDN转蝲  <a target="_blank">http://blog.csdn.net/pongba/archive/2007/05/16/1611593.aspx</a></p> <p>  1. <em><font face="宋体">大众是容易被误导的,我也曄是。以为掌握了更多的语al节更牛,但实际却是那些语al节十有八九是^时编E用都用不到的?/font></em><strong style="mso-bidi-font-weight: normal"><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'">C++</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">中众多的l节虽然在库设计者手里面有其用武之地Q但普通程序员则根本无需q多xQ尤其是没有实际动机的关?/span></strong><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">?/span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'"><a target="_blank"><span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"><span lang="EN-US"><font color="#0066ff">一般?/font></span></span></a></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">?/span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'"><a target="_blank"><span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"><span lang="EN-US"><font color="#0066ff">~码实践准则</font></span></span></a></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">Q以及基本的</span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'"><a target="_blank"><span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"><span lang="EN-US"><font color="#0066ff">~程能力和基本功</font></span></span></a></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">Q乃?/span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'"><a target="_blank"><span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"><span lang="EN-US"><font color="#0066ff">基本的程序设计理?/font></span></span></a></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">以及</span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'"><a target="_blank"><span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"><span lang="EN-US"><font color="#0066ff">法<span lang="EN-US">设计</span></font></span></span></a></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">。才是真正需要花旉掌握的东ѝ?/span></p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">  2. <em>熟练q用一门语al不意味着要把它的边边角角全都C</em>?em style="mso-bidi-font-style: normal">懂得一些常识,有了~程的基本直觉,遇到一些细节错误的时候再L书,是最节省旉的办?/em>?/span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">  3. <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">学习最佳编码实跉|学习</span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'">C++</span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">更重要。看优秀的代码也比埋头用差劲的编码方式写垃圾代码要有效。直接、清晰、明了?/span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'">KISS</span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">地表达意图比玩编码花招要重要</span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'">??XML:NAMESPACE PREFIX = O /?><o:p></o:p></span></span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">    4.q里是C++之父 Bjarne Stroustrup的关于如何学?span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Century Gothic'">C++</span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">Q以及编E)的看法的摘录Q?/span></span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">  Obviously, C++ is very complex. Obviously, people get lost. However, most peple get lost when they get diverted into becoming language lawyers rather than getting lost when they have a clear idea of what they want to express and simply look at C++ language features to see how to express it. Once you know data absreaction, class hierarchies (object-oriented programming), and parameterization with types (generic programming) in a fairly general way, the C++ language features fall in place.</span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">译:诚然QC++非常复杂。诚ӞZq失其中了。然而问题是Q大多数Z是因为首先对自己惌表达什么有了清晰的认识只不q在去C++语言中搜d适的语言Ҏ时q失的,相反Q大多数人是在不觉成a律师的\上迷失在l节的丛林中的。事实是Q只需Ҏ据抽象、类体系l构QOOPQ以及参数化cdQGPQ有一个相当一般层面的了解QC++UL的语aҎ也清晰v来了?/span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"> </span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'"> </span> </p> <p> <span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Century Gothic'; mso-hansi-font-family: 'Century Gothic'">  </span> </p> <img src ="http://www.aygfsteel.com/vagasnail/aggbug/301214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/vagasnail/" target="_blank">vagasnail</a> 2009-11-05 09:57 <a href="http://www.aygfsteel.com/vagasnail/articles/301214.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于函数http://www.aygfsteel.com/vagasnail/articles/301130.htmlvagasnailvagasnailWed, 04 Nov 2009 11:19:00 GMThttp://www.aygfsteel.com/vagasnail/articles/301130.htmlhttp://www.aygfsteel.com/vagasnail/comments/301130.htmlhttp://www.aygfsteel.com/vagasnail/articles/301130.html#Feedback0http://www.aygfsteel.com/vagasnail/comments/commentRss/301130.htmlhttp://www.aygfsteel.com/vagasnail/services/trackbacks/301130.html

#include<iostream>
#include "string"
using namespace std;
/*
size_t count_calls()
{
 static size_t ctr = 0;
 return ++ctr;
}
*/
//不可以间隔省Q不可以向后省,具体自己以编译器的角度理?br />/*
string screenInit(string::size_type height = 24,
      string::size_type width = 80,
      char background = ' ')
{
 return "";
}
*/

bool lengthCompare(const string &str1, const string &str2)//声明一个函?br />{
 if(str1.length() >= str2.length())
  return true;
 else
  return false;
}

void useBigger(const string &, const string &,
      bool(const string &, const string &));//函数指针作为参?br />void useBigger(const string &, const string &,
      bool (*)(const string &, const string &));//也可以这样传递函数指针?/p>

int (*ff(int))(int *, int);//q回指向函数的指针,需要从里往外理?br />//很难理解大致?有一个ff(int)函数Q他带有(int *, int)的参敎ͼq回一个int
//可用typedef化ؓ
typedef int (*FF)(int *, int)
FF ff(int)
//真鸡巴复?/p>


int main()
{
/* 
 typedef bool (*cmpFcn)(const string &, const string &); //只要函数cd相同皆可
 //所谓的函数cdQ是指函数参数及其类型、个数、顺序等Q还有返回?br /> cmpFcn pf1 = 0;
 cmpFcn pf2 = lengthCompare;
 pf2("111","2222");//直接引用函数名等效于在函数名上应用取地址操作W?br /> pf1 = pf2;
 pf1("2222","111");//不需要用解引用操作W?,直接通过指针调用函数?br />*/ 
/*
 for(size_t i = 0;i != 100; ++i)
  cout<<count_calls()<<endl;
 return 0;
*/

 

return 0;
}

 

最后加几点注意Q?/p>

1.  千万不要q回局部对象的引用Q因为局部对象已被回Ӟ所以引用将会变成空引用Q而返回对象执行的是值拷贝,也就是重新生成了一个对象?/p>

2. 如果不希望引用返回的D修改Q返回引用请声明为constQ同理Ş参也是一P如果不希望被修改误为const?/p>

3. 千万不要q回局部对象的引用Q基本和引用相同Q方法返回后局部对象被释放Q所以指针ؓ垂悬指针?/p>

4. 默认实参是通过lŞ参表中提供明的初始值来指定的。在函数声明中指定,而且在同一个文件中只能Z个函数指定一ơ?/p>



vagasnail 2009-11-04 19:19 发表评论
]]>
关于指针http://www.aygfsteel.com/vagasnail/articles/301128.htmlvagasnailvagasnailWed, 04 Nov 2009 11:18:00 GMThttp://www.aygfsteel.com/vagasnail/articles/301128.htmlhttp://www.aygfsteel.com/vagasnail/comments/301128.htmlhttp://www.aygfsteel.com/vagasnail/articles/301128.html#Feedback0http://www.aygfsteel.com/vagasnail/comments/commentRss/301128.htmlhttp://www.aygfsteel.com/vagasnail/services/trackbacks/301128.html

#include <iostream.h>
#include <string.h>
void main()
{
/* test 1 
 const int c_ival = 0;
 int *pi;
 pi = c_ival;//指针变量可以通过一个常量赋?br /> int ival = 2;//指针变量不可以通过一个变量赋?br /> //pi = 2; //M字面量,?外,都不可以l指针变量赋?br /> pi = 0; //指针只能通过字面?或者const?Q以及NULL预定义变量赋?br /> pi = NULL;//NULL是一个预处理变量Q也可以为指针变量赋倹{?br />*/

/* test 2
 double dval;
 double *pd = &dval;//可通过变量的地址(指针)l指针变量赋?br /> double *pd2 = pd; //同类型的指针变量可以赋?br />// int *pi = pd;   //不同cd的当然不能复制了
// int *pi = &dval; //cd不同的变量的指针不能互相赋?br />*/

/* test 3
 double obj = 3.14;
 double *pd = &obj;//OK,不多?br /> void *pv = &obj;
 pv = pd;
 int *pi;
 //pi = &2;//不能对常量取地址?br /> int iv = 11;
 pi = &iv;
 pv = pi;//cd相同的变量才可以赋|而且void*型指针可以保持Q何对象的地址
 //void*指针只能用于比较Q传参,不可以操作其指向的对?br />*/

 /**
  友情提供Q?br />  指针和引用的比较Q?br />  虽然引用(reference)和指针都可以间接讉K另一个|但它们之间有两个主要的区别?br />  W一个区别在于引用L指向某个对象Q定义引用时没有初始化是错误的。第二个重要
  的区别则是赋D为的差异Q给引用赋g改的是该引用所兌的对象的|而ƈ不是
  使引用与另一个对象关联。应用一l初始化Q就始终指向同一个特定的对象?br /> */

/* test 4
 int ival = 1024, ival2 = 2048;
 int *pi = &ival, *pi2 = &ival2;
 pi = pi2;
//正确
 int &ri = ival, &ri2 = ival2;
 ri = ri2;
 cout<<"ri = "<<ri<<", ri2 = "<<ri2<<endl;
 //output :ri = 2048, ri2 = 2048
 //注意q里q没有改变ri与ri2的指向,而是改变他们所各自兌的对象的倹{?br />*/

/* test 5
 int ival = 1024;
 int *pi = &ival;
 int **ppi = &pi; //C++使用**操作W指z一个指针指向另一个指针?*也是指向W?br /> //下面相同的|相同的对?br /> cout<<ival<<" "<<*pi<<" "<<**ppi<<endl;
*/

//忍不住了Q讨ZQconst引用
 //正解Qconst引用是指向const对象的引用?br /> //const int ival = 1024; //引用必须初始?br /> //const int &refVal = ival;
 //int &ref2 = ival;//非常量对象的引用不可以指向常量对象的引用

// const int &refVal2 = 2;//const引用可以以字面量初始?br />// int vali = 1111;
// const int &refVal3 = vali;//const引用可以以变量初始化Q但是通过该引用访问该变量Q就只能当做帔R使用?br />// refVal3 = 100; 不可修改Q表明这里是该引用指向了一个常量对象?br /> //l-value左|左值是变量Q可左可叟?r-value叛_|叛_是帔R(包括字面?Q只能右

 /*
  在指针上加上(或减?一个整形数值n{效于获得一个新指针Q该新指针指向指针原来指向的元素之后
  (或之?的第n个元素?br />  两个指针减法操作的结果是标准库类型ptrdiff_t的数据。这是一个signed整ŞQ它表示两个指针之间
  的差距?br /> */     
/* test 6
 const size_t arr_sz = 5;
 int int_arr[arr_sz] = {0, 1, 2, 3, 4};
 for(int *pbegin = int_arr, *pend = int_arr + arr_sz;
   pbegin != pend; ++pbegin)
   {
   // cout<<int_arr[5]; Z么会输出5Q诡异啊?br />    cout<<*pbegin<<' ';
   }
*/

 //指向const对象的指针和const指针
 //指向const对象的指针这样声?const double *cptr;
 //1. 不能修改所指对象的|因ؓ是const对象嘛?br /> //*cptr = 42; //q是错误的?br /> //2. 不能使用void*指针保持const对象的地址Q而必M用const void*?br />// const int universe = 42;
// const void *cpv = &universe;
// void *pv = &universe; //错误的,必须使用const void*
 //3. 对于非const对象的处理和const引用是一L?br /> //但是我们可以修改指针变量的|使我们的指针指向新的对象。只是这个对象无论是否ؓconst
 //只要我们通过q个指针讉KQ那么系l都认ؓ其ؓconst?自以为指向const的指?

 //const指针是这?double *const cptr;
 //指针变量的本w的值无法修改,也就是指针无法执行初始指定的对象的|
 //q样和const引用则比较像?但是我们可以修改我们所执行的对象?/p>

/*
 double dval = 33.33;
 double *const cptr = &dval;
 *cptr = 332.02;
 cout<<dval<<" "<<*cptr;
 //下面最变态的Q指向const对象的const指针
 const double pi = 3.14159;
 const double *const pi_ptr = &pi;
 //从右向左读,关于指针都一般都q么读,既不可以修改指针所指向的对象的|也不可以修改该指针的指向?br />*/
/*
 //typedef和指?不多说反正记得typedef不是单的文本扩展Q其实只要注意const应该写在cd后面可以了
 //所以:
 //下面
 typedef string *pstring;
 const pstring cstr;
 //{h?br /> string *const cstr;//也就是const指针?br />*/

}

 

再加一点,天亮了要睡觉了啊Q?/p>

#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <string>
using namespace std;
void main()
{
 const char *cp1 = "A string example";
 const char *cp2 = "A different string";
// int i = strcmp(cp1, cp2);
// printf("%d\n", i);
// i = strcmp(cp2, cp1);
// printf("%d\n", i);
// i = strcmp(cp1, cp1);
// printf("%d\n", i);

// char largeStr[16 + 18 + 2];
// strcpy(largeStr, cp1);
// printf("%s\n", largeStr);
// strcat(largeStr, " ");
// strcat(largeStr, cp2);
// printf("%s\n", largeStr);

// char ca[] = {'C', '+', '+', '\0'};
// cout<<strlen(ca)<<endl; I格q不是null


 int ia[3][4] = {
  {0, 1, 2, 3},
  {4, 5, 6, 7},
  {8, 9, 10, 11},
 };

 typedef int int_array[4];
 int_array *ip = ia;

 for(int_array *p = ia; p != ia + 3; ++p)
  for(int *q = *p; q != *p + 4; ++q)
   cout<< *q <<endl;

 //可用数l长度后面的一对圆括号Q对数组元素做值初始化:
  int *pia2 = new int[10]();
 // q里初始化ؓ0
 // 允许定义cȝ型的const数组Q但该类型必L供默认的构造函?br /> // const string *pcs = new const string[100];//g不支? 而且没有必要Q?br />  //因ؓstring早已做好了相关的支持?br />  //q里׃使用默认构造函数来初始化数l元?br />  //使用delete [] 数组?来释放数l空间?br />  //delete [] pcs;
  delete [] pia2;

}

 



vagasnail 2009-11-04 19:18 发表评论
]]>
վ֩ģ壺 ij| ˳| ͭɽ| Զ| | ƽ| °Ͷ| Һ| | | | ɽ| | | | | ʡ| פ| Ͽ| ƽ| | ɽʡ| | | | ˳| Ƹ| غ| | | | | Ʊ| | ½| û| | | | Դ| |