I have a class that defined a custom operator for TCHAR *, so that
CMyClass::operator const TCHAR*() const
{
}
I want to be able to do something like
CMyClass myClass;
_tprintf(_T("%s"), myClass);
or even
_tprintf(_T("%s"), CMyClass(value));
But when you try printf always prints (null) instead of a value. I also tried the usual char * operator, as well as options with constant, etc. It only works correctly if I explicitly call the operator or perform an acting mood, for example
_tprintf(_T("%s\n"), (const TCHAR*)myClass);
_tprintf(_T("%s\n"), myClass.operator const TCHAR *());
However, I do not want to quit. How can this be achieved?
Please note that it is possible to create a function that has the const parameter TCHAR *, so that it forcibly calls the TCHAR * operator, but I also do not want to implement this.