Thread: class template and operator=()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    class template and operator=()

    Hey all, I'm working on a general (hopefully very useful) list class template. At the moment I'm stuck with dev-cpp giving me weird errors about my operator=() function:
    Code:
    template<class item_t>
    mylist& mylist<item_t>::operator=(const mylist list2) {
      mylist list1;
      list1.length = list2.length;
      int i;
      delete [] list1.list;
      list1.list = new item_t[list2.length];
      for (i = 0; i < list1.length; ++i)
        list1.list[i] = list2.list[i];
      return list1;
    }
    I'm not real familiar with templates so this is probably something super basic and obvious, but any help would be greatly appreciated, thx.
    Last edited by ichijoji; 10-04-2003 at 09:08 PM.
    Illusion and reality become impartiality and confidence.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  3. Replies: 6
    Last Post: 12-06-2005, 09:23 AM
  4. Syntax problems with Class Template
    By cuddlez.ini in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2004, 07:25 PM
  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