My test class XString
has two cast operators. But the compiler do not use the explicit cast operator const wchar_t*()
for fooA
. Why?
class XString
{
public:
operator const CString&();
explicit operator const wchar_t*();
};
void fooA(const wchar_t* s);
void fooB(const CString& s);
void test()
{
XString x;
CString c = x; //OK
fooA(x); //Error C2664: 'void fooA(const wchar_t *)': cannot convert argument 1 from 'XString' to 'const wchar_t *'
fooB(x); //OK
}