Thread: member function specialization

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    member function specialization

    Hi,

    I have a problem with templated member function ( partial? ) specialization.

    .h:
    Code:
    class a : public b< int >
    {
    public:
        template< class DATA >
        void foo( int id,DATA pack )
        {
             ...
        }
    };
    .cpp :
    Code:
    template<>
    void a::foo< int >( int id,int pack )
    {
        ...
    }
    With this I get the multiple definition of ... error.

    Anyone knows how to implement this correctly?

    Regards,
    Domen

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You cannot specialize a function template -- you overload it instead. Just write:

    Code:
    void a::foo( int id,int pack )

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    11
    Works now. Thanks for the answer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-19-2008, 12:06 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  5. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM