mickey
23rd February 2008, 18:11
hello, I've got one class constructor with two option parameter; so I can create the object like this:
Myobj::Myobj( char* parone="", char* partwo="") :
_name(parone), _value(partwo) {........}
Myobj obj(); // in this case warning
Myobj obj("one", "two"); //this ok.
//warning is: prototyped function not called (was a variable definition intended?)
I suppose that to using default parameters is necessary has first parameters not default. Is this? Anyway: I'd like avoid a second constructor because I had to duplicate its contents (and It could be large). Ideas?
THanks..
Myobj::Myobj( char* parone="", char* partwo="") :
_name(parone), _value(partwo) {........}
Myobj obj(); // in this case warning
Myobj obj("one", "two"); //this ok.
//warning is: prototyped function not called (was a variable definition intended?)
I suppose that to using default parameters is necessary has first parameters not default. Is this? Anyway: I'd like avoid a second constructor because I had to duplicate its contents (and It could be large). Ideas?
THanks..