<fa*************@free.fr> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
: If we define such conversion operator for Zclass :
:
: class ZClass {
:
: operator char*(void);
: };
:
: How can we write explicit conversion without using this :
:
: typedef char* charPtr; // Tricky way.
: ZClass xmpl(...);
: char* s =charPtr(xmpl);
:
: (char* s; s =xmpl; would work but how cleanly write EXPLICIT conversion
: ?)
Are you looking for the following syntax ? :
char* s = xmpl.operator char*();
This explicitly calls the conversion operator.
Besides that, you have a choice of:
char* s = static_cast<char*>(xmpl); // C++-style cast
char* s = (char*)xmpl; // C-style cast
.... and probably more...
hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com