Hi
[SOURCE]
class A
{
public:
A(){}
~A(){}
virtual operator const char*() const
{
return "A";
}
};
class B : public A
{
public:
B(){}
~B(){}
operator const char*() const
{
return "B";
}
};
int main()
{
B b;
A* a = &b;
const char* str = (const char*)a;
}
[/SOURCE]
I debug the code and none of the operators get called. (if "a" were not a pointer it works fine ).
if you type:
[SOURCE]
const char* str = a->operator const char*(); // This works fine
[/SOURCE]
Why the first version did not worked?
tnx,