Thread: C++ template error I think?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    186

    C++ template error I think?

    I'm new to C++ but we're supposed to implement a provided template for a linked list. The error I'm getting says:
    Code:
    ..\src\dlist.cc:3: error: expected constructor, destructor, or type conversion before '<' token
    I get this error for my constructor methods in my .cc file. Without giving too much away, here is what my code looks like:
    Code:
    //Constructor
    template <typename T>
    Dlist<T>::Dlist()
    {
    	makeEmpty();
    }
    
    //Copy constructor
    template <typename T>
    Dlist<T>::Dlist(const Dlist &l)
    {
    	makeEmpty();
    	copyAll(l);
    }
    
    //Destructor
    template <typename T>
    Dlist<T>::~Dlist()
    {
    	makeEmpty();
    	removeAll();
    }
    
    //Equals operator
    template <typename T>
    Dlist<T>& Dlist<T>::operator=(const Dlist &l)
    {
    	if(this!=&l)
    		copyAll(l);
    	return *this;
    }
    //more methods
    I'm certain that the header is correct because it was provided. I think I'm just doing something stupidly wrong.

    PS. The other methods all say:
    Code:
    error: expected initializer before '<' token
    Last edited by jcafaro10; 01-13-2009 at 11:53 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