Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > default constru...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4081 of 4215
Post > Topic >>

default constructor and object initialization

by Michel Leunen <michel@[EMAIL PROTECTED] > Mar 25, 2008 at 09:27 PM

Hi,

Is there a difference between default constructor and user defined 
constructor regarding initialization of objects?

For instance :

struct S
{
   //S();
};

const S s;

doesn't compile  because s is not initialized at the moment of its 
declaration. if I uncomment the constructor, it compiles without error.

My question: doesn't the default constructor have to default initialize 
the object? Obviously, it's not the case. Why  have I to provide my own 
constructor in this case?

Michel
-- 
Michel Leunen
http://linux.leunen.com
 




 3 Posts in Topic:
default constructor and object initialization
Michel Leunen <michel@  2008-03-25 21:27:24 
Re: default constructor and object initialization
"Alf P. Steinbach&qu  2008-03-25 22:44:52 
Re: default constructor and object initialization
Michel Leunen <michel@  2008-03-26 20:24:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 21:32:32 CDT 2008.