operator=

This is a discussion on operator= within the C++ Programming forums, part of the General Programming Boards category; I'm trying to overload the = operator, and i get this error: CBasicTemplateList.cpp(58) : error C2244: 'CTemplateList<T>::=' : unable to ...

  1. #1
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    operator=

    I'm trying to overload the = operator, and i get this error:
    CBasicTemplateList.cpp(58) : error C2244: 'CTemplateList<T>::=' : unable to resolve function overload

    Any ideas why?

    The prototype is:
    CTemplateNode<T>& operator=(const CTemplateList<T>& list);

    Code:
    template <class T>
    CTemplateList<T>& CTemplateList<T> :: operator=(const CTemplateList<T>& list)
    {
    this->m_pNHead=list.m_pNHead;
    this->m_pNTail=list.m_pNTail;
    this->m_pNCurrent=list.m_pNCurrent;
    
    return *this;
    }

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136

    Re: operator=

    Originally posted by gazsux
    The prototype is:
    CTemplateNode<T>& operator=(const CTemplateList<T>& list);

    Code:
    template <class T>
    CTemplateList<T>& CTemplateList<T> :: operator=(const CTemplateList<T>& list)
    {
    this->m_pNHead=list.m_pNHead;
    this->m_pNTail=list.m_pNTail;
    this->m_pNCurrent=list.m_pNCurrent;
    
    return *this;
    }
    The prototype should match the function. Your prototype returns a CTemplateNode reference; while, the actual function returns a CTemplateList reference.

  3. #3
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    ahh alas it has been a long long day... ty good sir

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LinkedList operator= and deep copy
    By sethjackson in forum C++ Programming
    Replies: 11
    Last Post: 02-28-2008, 11:54 AM
  2. SLList operator= overloading problems
    By JoeS in forum C++ Programming
    Replies: 8
    Last Post: 12-08-2004, 10:16 AM
  3. class template and operator=()
    By ichijoji in forum C++ Programming
    Replies: 4
    Last Post: 10-04-2003, 11:42 PM
  4. Copy constructors and operator=()
    By filler_bunny in forum C++ Programming
    Replies: 13
    Last Post: 08-25-2003, 07:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21