c++ - template method overrides non-template method -


I want to put a shared object (objects, objects, etc.) in one shared_ptr. So I created the base class and used share_ptr.

But, how can I declare

  T getMember ()?   

In the base class, can I call objectbase.getmail?

  class objectbase {public: // get virtual mismatch? }; Template & lt; Typename T & gt; Class Object: Public ObjectBase {Public: Object (T X): Member (X) {} T Milllem () {Return Member; Private: Tee Member; };    

You can not show how such an announcement should be made, that it can be used for all types of types Can return? it's not possible. You can see the objectbase * correct object & lt; T & gt; * and then use the getMember function. It is possible only if all T share a common base class so that you can return an indicator to it but it will put a strict restriction on T .

Comments