Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: benefit of class constructor initial list

Thread Tools

Re: benefit of class constructor initial list

Posts: n/a
On Nov 27, 5:10 pm, dongfei <(E-Mail Removed)> 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?
Exellent explanation.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call an inherited, template class constructor from initializerlist of an inheriting, non-template class constructor C++ 2 11-14-2008 10:04 PM
A constructor calling another constructor (default constructor)? Generic Usenet Account C++ 10 11-28-2007 04:12 AM
call base class constructor from derived class constructor Rahul C++ 16 11-07-2007 03:40 PM
Calling base class constructor from derived class Copy constructor ali C++ 4 03-05-2007 09:15 AM
Invoking templatized base class constructor from templatized derived class constructor mrstephengross C++ 5 05-18-2005 07:12 PM