5 Jul
2008
5 Jul
'08
4:06 p.m.
No, as I read it, the original author was not interested in covariant return types, he was asking how to solve the problem of writing clone methods for polymorphic classes. The solution is to *not* use covariant return types. This avoids the problem where shared_ptr<A> is a completely different and non-castable type to shared_ptr<B> - but if you do it the non-covariant way you don't have this problem because all your clone functions return shared_ptr<A>. Problem solved. You'll get further in life if you make positive contributions, rather than putting down other people's. Rodolfo Lima wrote:
And apparently you've forgotten what covariant return types are :)
Regards, rod