I have a conversion like this:
Class1 *p1;
Class2 *p2 = new Class2();
p1 = (Class1 *) p2;
Can I override the typecast operator above to return a custom Class1 object pointer? If yes how?
EDIT: My exact problem is that I have code like this:
if (*$1 == ArrayType(AnyType()))
{
$$ = ((ArrayType *) $1)->getElementsType();
}
Operator == is overloaded so $1 may be of type AnyType *.