﻿<?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-随笔分类-C++之路</title><link>http://www.cppblog.com/quite/category/665.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 23 May 2008 09:17:54 GMT</lastBuildDate><pubDate>Fri, 23 May 2008 09:17:54 GMT</pubDate><ttl>60</ttl><item><title>05-12-27</title><link>http://www.cppblog.com/quite/archive/2005/12/27/2193.html</link><dc:creator>quite</dc:creator><author>quite</author><pubDate>Tue, 27 Dec 2005 14:48:00 GMT</pubDate><guid>http://www.cppblog.com/quite/archive/2005/12/27/2193.html</guid><wfw:comment>http://www.cppblog.com/quite/comments/2193.html</wfw:comment><comments>http://www.cppblog.com/quite/archive/2005/12/27/2193.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/quite/comments/commentRss/2193.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/quite/services/trackbacks/2193.html</trackback:ping><description><![CDATA[<P>类中的数据成员按成员在类定义中的声明顺序进行构造，而不是按构造函数说明中冒号后面的顺序进行构造的。<BR>如下面的例子：<BR><BR>#include&lt;iostream&gt;<BR>using namespace std;</P>
<P>class a<BR>{<BR>public:<BR>&nbsp;a(int j):age(j),num(age+1)<BR>&nbsp;{<BR>&nbsp;&nbsp;cout&lt;&lt;"age:"&lt;&lt;age&lt;&lt;"&nbsp; ,num:"&lt;&lt;num&lt;&lt;endl;<BR>&nbsp;}</P>
<P>protected:<BR>&nbsp;int num;<BR>&nbsp;int age;<BR>};</P>
<P>int main()<BR>{<BR>&nbsp;a sa(15);<BR>&nbsp;return 0&nbsp; ;<BR>}</P>
<P>由于mun 先于 age 构造，故&nbsp; num=age+1; 是个随机数。</P>
<P>&nbsp;</P>
<P>&nbsp;</P><img src ="http://www.cppblog.com/quite/aggbug/2193.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> 2005-12-27 22:48 <a href="http://www.cppblog.com/quite/archive/2005/12/27/2193.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>