This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++: Function style initializer


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]