Original Post
For class T1 I can define a type conversion operator to T2 as T1::opeator T2(). I try it and it works as expected. How do you do a pointer though? The compiler accepts T1::operator T2*(), but it doesn''t actually call it when I try T2 *pt2 = (T2 *)pt1 or T2 *pt2 = pt1. When I try it as a non-member function I get an error saying it must be a member function.
If you are wondering why...
Another post on here someone''s compiler isn''t correctly casting pointers to a derived class with multiple bases to pointers to the secondary bases. It is possible to do it explicitly which then makes it nice if you can add the operator to the derived class. It''s a hack, but at least on a compiler that does the cast correctly you could just remove the operator from the class definition. With anything you would have to actually change the code using the class rather than just the class.