c++: Function style initializer

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

 



Hi,
I experienced something I consider strange: Let me try to explain by a simpe example:

Definitions:

class B;

class A {
A(B par=0);
}

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. I thought that because of the default value in the constructor, I could create myA
this way, but I get no error nor object. I was beaten by this last week, and it cost me many hours to debug. Am I missing something? Forgive me if the answer is trivial, I am not an expert in c++ and besides I started coding again after more than a year. Pointers are also appreciated, I have the latest Stroustrup's but I just started it and a search didn't answer this question.

jorges



      ______________________________________________ 
Enviado desde Correo Yahoo! La bandeja de entrada más inteligente.


[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