Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: benefit of class constructor initial list (http://www.velocityreviews.com/forums/t646315-re-benefit-of-class-constructor-initial-list.html)

maverik 11-27-2008 02:15 PM

Re: benefit of class constructor initial list
 
On Nov 27, 5:10 pm, dongfei <dongfei...@gmail.com> wrote:
> Hi, I have a confusion that what's the benefit of class constructor
> initial list.
> ex:
> (1)
> class A{
> public: A(int i, const string& str):_i(i),_str(str){};
> private:
> int _i;
> string _str;
>
> };
>
> (2)
> class B{
> public: B(int i, const string& str):{
> _i = i;
> _str = str;};
>
> private:
> int _i;
> string _str;
>
> };
>
> Is class A is superior to class B?


http://www.parashift.com/c++-faq-lit....html#faq-10.6
Exellent explanation.


All times are GMT. The time now is 02:38 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.