Thread: How properly inherit from template?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    184

    How properly inherit from template?

    Is this correct or are the functions not properly overriding?

    Code:
    template <typename T>
    class Test
    {
         T* get();
         void destroy();
    };
    
    template <typename T> T* Test<T>::get()
    {
     ....
    }
    
    template <typename T> void Test<T>::destroy()
    {
     ....
    }
    
    //Now the class that inherits
    class SomeClassTest : public Test<SomeClass>
    {
         SomeClass* get();
         void destroy();
    };
    
    SomeClass* SomeClassTest::get()
    {
         ...elided...
         return ( SomeClass* ) Test<SomeClass>::get();
    }
    
    void SomeClassTest::destroy() 
    {
         ...elided...
    }
    Last edited by 6tr6tr; 04-22-2008 at 02:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM