c++ - Select from two overloaded methods -
there class 2 similar constructors...
class cx { public: cx(header header, __int64 i64id); cx(header header, const char* pszname); // other methods... }; i want call second constructor null pointer.
cx *data1 = new cx(&header, null); //it ambiguous call overloaded function cx *data2 = new cx(&header, (const char*)null); // correct, against our coding standards... cx *data3 = new cx(&header, static_cast<const char*>(null)); // correct, agains our coding standards... const char* pszname = null; cx *data4 = new cx(&header, pszname); // correct waste of stack. is there better way how select constructor?
(nullptr solution in case, it's not possible because should compilable in vc6)
you can modify 2nd constructor taking null default argument , call passing first argument argument
cx(header header, const char* pszname=null);
Comments
Post a Comment