c++: Function style initializer
me22
me22.ca@gmail.com
Tue May 13 19:14:00 GMT 2008
On Tue, May 13, 2008 at 7:35 AM, Dario Saccavino <kathoum@gmail.com> wrote:
> 2008/5/13 <jorgesmbox-ml@yahoo.es>:
>
> > Now, if I use:
> >
> > A myA(myB); // assume myB is of type B
> >
> > then I have an object of type A created, but if I do:
> >
> > A myA();
> >
> > Then no object of type A is created.
>
> In the second case you are declaring a function. The correct declaration is
>
> A myA;
>
> See http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.2
>
You will also sometimes want
A myA = A();
if you have a POD type that you want value-initialized.
( Which is not the case you have here, but is related. )
More information about the Gcc-help
mailing list