How to write a function which returns itself in an extend class?

In reply to aaubertin:
FYI: normally clone() is declared virtual and virtual methods that return a type of itself are allowed to return an extension of itself when extending the method. This is known as a Covariant Return Type.