﻿<?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++博客-quitewalk-随笔分类-求助</title><link>http://www.cppblog.com/quite/category/807.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 21 May 2008 17:04:34 GMT</lastBuildDate><pubDate>Wed, 21 May 2008 17:04:34 GMT</pubDate><ttl>60</ttl><item><title>求前辈指点一下，谢谢了．</title><link>http://www.cppblog.com/quite/archive/2006/02/28/3588.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Tue, 28 Feb 2006 14:55:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2006/02/28/3588.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/3588.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2006/02/28/3588.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/3588.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/3588.html</trackback:ping><description><![CDATA[<P>//这是个关于函数模板的问题,不明白为什么会出现这样的错误,希望前辈们花二分钟看一下,拜托了啊。　（这是&lt;C++&nbsp; Pirmer&nbsp; Plus &gt;第五版<BR>//中的程序,我用的是 Visual C++6.0）</P>
<P><BR>#include&lt;iostream&gt;<BR>using namespace std;</P>
<P>template &lt;class type&gt;<BR>void swap(type &amp;a,type &amp;b)<BR>{<BR>&nbsp;type temp;<BR>&nbsp;a=b;<BR>&nbsp;b=temp;<BR>}</P>
<P>int main()<BR>{<BR>&nbsp;int i=10;<BR>&nbsp;int j=20;</P>
<P>&nbsp;cout&lt;&lt;"i,j="&lt;&lt;i&lt;&lt;","&lt;&lt;j&lt;&lt;endl;<BR>&nbsp;cout&lt;&lt;"Using compiler_generated int swapper:\n";</P>
<P>&nbsp;swap(i,j);</P>
<P>&nbsp;cout&lt;&lt;"Now,i,j="&lt;&lt;i&lt;&lt;","&lt;&lt;j&lt;&lt;endl;</P>
<P>&nbsp;/*double x=24.5;<BR>&nbsp;double y=81.7;</P>
<P>&nbsp;cout&lt;&lt;"x,y="&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;endl;<BR>&nbsp;cout&lt;&lt;"Using compiler_generated double swapper:\n";<BR>&nbsp;swap(x,y);<BR>&nbsp;cout&lt;&lt;"Now x,y="&lt;&lt;x&lt;&lt;","&lt;&lt;y&lt;&lt;endl;*/</P>
<P>&nbsp;return 0;<BR>}</P>
<P><FONT color=#008000>error C2667: 'swap' : none of 2 overload have a best conversion<BR>E:\Documents and Settings\bing\桌面\8.11_funtemp.cpp(14) : error C2668: 'swap' : ambiguous call to overloaded function</FONT></P><img src ="http://www.cppblog.com/quite/aggbug/3588.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/quite/" target="_blank">quite</a> 2006-02-28 22:55 <a href="http://www.cppblog.com/quite/archive/2006/02/28/3588.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>string 类 的  getline</title><link>http://www.cppblog.com/quite/archive/2006/02/26/3509.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Sun, 26 Feb 2006 03:17:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2006/02/26/3509.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/3509.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2006/02/26/3509.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/3509.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/3509.html</trackback:ping><description><![CDATA[<P>／／<FONT color=#008000>为什么结果少输出一条数据？是不是 getline()函数有什么问题？请指教，谢谢！(我用的是&nbsp; visual c++ 6.0)</FONT><BR>#include&lt;iostream&gt;<BR>using namespace std;<BR>#include&lt;vector&gt;<BR>#include&lt;string&gt;<BR>int main()<BR>{<BR>&nbsp;int NUM;<BR>&nbsp;cout&lt;&lt;"input vetcor size NUM=";<BR>&nbsp;cin&gt;&gt;NUM ;</P>
<P>&nbsp;vector&lt;string &gt;str_arr(NUM);</P>
<P>&nbsp;for(int i=0;i&lt;NUM;i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;cout&lt;&lt;"enter the "&lt;&lt;i+1&lt;&lt;"&nbsp;&nbsp; string:";<BR>&nbsp;&nbsp;getline(cin,str_arr[i]);<BR>&nbsp;&nbsp;//arr.push_back(x);<BR>&nbsp;}</P>
<P>&nbsp;for(i=0;i&lt;NUM;i++)<BR>&nbsp;&nbsp;cout&lt;&lt;str_arr[i]&lt;&lt;endl;</P>
<P>&nbsp;cout&lt;&lt;endl&lt;&lt;endl;<BR>&nbsp;return 0;<BR>}<BR></P><img src ="http://www.cppblog.com/quite/aggbug/3509.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/quite/" target="_blank">quite</a> 2006-02-26 11:17 <a href="http://www.cppblog.com/quite/archive/2006/02/26/3509.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>困惑</title><link>http://www.cppblog.com/quite/archive/2006/02/24/3458.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Fri, 24 Feb 2006 04:35:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2006/02/24/3458.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/3458.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2006/02/24/3458.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/3458.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/3458.html</trackback:ping><description><![CDATA[<P>&nbsp;　　请问，学C++到底可以用来做什么？<BR>&nbsp; 　　我知道这个问题对于大多数人来说真的是很明了的事情，但是对于像我这样呆在学校里的学生来说，认真思考一下，真的是很不明了，我只知道，C++ 是一门很优秀的编程语言，Visual C++&nbsp; 是可视化编程。走怎样的路才能做出自己的软件？好想好想知道．</P>
<P>&nbsp; 　　真的很困惑，请大家不吝指点迷津。</P><img src ="http://www.cppblog.com/quite/aggbug/3458.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/quite/" target="_blank">quite</a> 2006-02-24 12:35 <a href="http://www.cppblog.com/quite/archive/2006/02/24/3458.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>请问什么叫"释放内存"?</title><link>http://www.cppblog.com/quite/archive/2006/02/23/3447.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Thu, 23 Feb 2006 07:55:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2006/02/23/3447.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/3447.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2006/02/23/3447.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/3447.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/3447.html</trackback:ping><description><![CDATA[<P>//请问什么叫“释放内存”？</P>
<P>#include&lt;iostream&gt;<BR>int main()<BR>{<BR>&nbsp;using namespace std;<BR>&nbsp;int *ps=new int;<BR>&nbsp;int *pq=ps;<BR>&nbsp;*ps=4;<BR>&nbsp;cout&lt;&lt;*ps&lt;&lt;endl&lt;&lt;endl&lt;&lt;*pq&lt;&lt;endl&lt;&lt;endl;//输出两个&nbsp; 4</P>
<P>&nbsp;delete pq;<BR>&nbsp;//delete ps;&nbsp; 加上这条语句后，下条语句不会输出，另外，系统报错。</P>
<P>&nbsp;cout&lt;&lt;*ps&lt;&lt;endl&lt;&lt;endl;//-527665236&nbsp; ？？？不明白到底什么叫释放内存。另外，“一般来说，不要<BR>&nbsp;//创建两个指向同一个内存块的指针，因为这样将增加错误地删除同一个内存块两次的可能性”<BR>&nbsp;//为什么同一个内存块不能删除两次？理论上是没有必要，但真正这样做了，会有什么后果？？</P>
<P>&nbsp;return 0;<BR>}</P><img src ="http://www.cppblog.com/quite/aggbug/3447.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/quite/" target="_blank">quite</a> 2006-02-23 15:55 <a href="http://www.cppblog.com/quite/archive/2006/02/23/3447.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>请教，谢谢啦！</title><link>http://www.cppblog.com/quite/archive/2006/02/20/3350.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Mon, 20 Feb 2006 06:59:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2006/02/20/3350.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/3350.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2006/02/20/3350.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/3350.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/3350.html</trackback:ping><description><![CDATA[<FONT face=Verdana><STRONG>//我用以下程序测试机器所用的基本类型的字节数，有一点不明白，“SHRT_MAX:32767 &nbsp; &nbsp;4”？？请指点迷津。谢谢！<BR><BR>#include&lt;iostream&gt;<BR>using namespace std;<BR><BR>int main()<BR>{<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; cout&lt;&lt;"INT_MAX:"&lt;&lt;INT_MAX&lt;&lt;" &nbsp; "&lt;&lt;sizeof(INT_MAX)&lt;&lt;endl<BR>&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;"SHRT_MAX:"&lt;&lt;SHRT_MAX&lt;&lt;" &nbsp;"&lt;&lt;sizeof(SHRT_MAX)&lt;&lt;endl<BR>&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;"LONG_MAX:"&lt;&lt;LONG_MAX&lt;&lt;" &nbsp;"&lt;&lt;sizeof(LONG_MAX)<BR>&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;endl&lt;&lt;endl;<BR>&nbsp; &nbsp; <BR><BR>&nbsp; &nbsp; return 0;<BR>}<BR><BR>/*output:<BR>&nbsp; &nbsp;INT_MAX:2147483647 &nbsp; 4<BR>&nbsp; &nbsp;SHRT_MAX:32767 &nbsp; &nbsp;4<BR>&nbsp; &nbsp;LONG_MAX:2147483647 &nbsp; 4 &nbsp;<BR>*/<BR></STRONG></FONT><img src ="http://www.cppblog.com/quite/aggbug/3350.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/quite/" target="_blank">quite</a> 2006-02-20 14:59 <a href="http://www.cppblog.com/quite/archive/2006/02/20/3350.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>