Re: c++: Function style initializer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 13, 2008 at 7:35 AM, Dario Saccavino <kathoum@xxxxxxxxx> wrote:
> 2008/5/13  <jorgesmbox-ml@xxxxxxxx>:
>
> >  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. )

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux