Re: c++: Function style initializer

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

 



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

  Dario

[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