Hey guys, first of all thanks for the time to even read this. Basically, Ive had some trouble in figuring out how to get this operator overloading to work. I think I'm having trouble in the functions calls that are within this function. These functions that are giving me trouble currently do not get the job done, which isnt really my main problem. Im having trouble understanding the syntax of calling the functions that are used within them. Any help would be greatly appreciated.

The current situation:
templatized class object of List<L>
another class object of List<L>::Iterator
and another one for the nodes

here is the implementation sections for the copy function and the operator = function in which I am having trouble...

Copy Function:

template <typename L>
    List<L>::List(const List<L>& another)
    {
       List<L> ();
       Iterator<L> begin;
       another.Iterator<L>::begin;
       while (another.Iterator != last)
       {
          insert(another.Iterator<L>::get());
          another.Iterator<L>::next;
       }
       if (another.Iterator==last)
       {
          insert (another.Iterator<L>::get());
       }
    }

The implementation of the = operator overloading

template <typename L>
    const List<L> List<L>::operator=(const List<L>& another)
    {
       List<L> anotherTemp(const List<L>& another);
       anotherTemp.Iterator<L> begin();
       while (anotherTemp.Iterator != anotherTemp.last)
       {
          pushback (anotherTemp.Iterator->data);
          anotherTemp.Iterator.next();
       }
       pushback (anotherTemp.Iterator->data);
       return *this;
    }

Im not really worried about functionality currently (i can work on that later,) im just worried about getting it to compile with the proper syntax (which you can probably tell I am having trouble with.) Currently, my largest problem is getting my copy constructor to get the outcome to be of a class type =(

The following are the various errors I am getting:
basically a couple others like this:
68:error: 'anotherTemp' is not a class or namespace
71:error: request for member 'Iterator' in 'anotherTemp [with L=std::string]', which is of non-class type 'List(std::string) ()(const List(std::string)&)'

one more is 76:error: 'pushback' was not declared in this scope
( Here is the pushback declaration: void pushBack(L s); )

thanks again, if this is too much or too little lemme know! thanks again!

EDIT::: its a doubly linked array, my topic was wrong im sorry!

template <typename L>
    const List<L> List<L>::operator=(const List<L>& another)
    {
       List<L> anotherTemp(const List<L>& another);
       anotherTemp.Iterator<L> begin();
       while (anotherTemp.Iterator != anotherTemp.last)
       {
          pushback (anotherTemp.Iterator->data);
          anotherTemp.Iterator.next();
       }
       pushback (anotherTemp.Iterator->data);
       return *this;
    }

sorry, poor mistake, and cant edit anymore =(
line 68 in error translates to line 5 in this part of code...which has recently been edited from "anotherTemp.Iterator<L> begin();" to "anotherTemp::begin();"

line 71 translates to line 8, etc. =)

ok i pretty much said scratch that to iterators and started using temp nodes,,,something im a little more familiar self
so heres my improvised copy constructor:

template <typename L>
    List<L>::List(const List<L>& another)
    {
       List<L> copy;
       Node<L>* temp = another.first;
       temp->next=another.first->next;
       while (temp != another.last)
       {
          copy.pushBack(temp->data);
          temp=temp->next;
       }
       if (temp==another.last)
       {
          copy.pushBack(temp->data);
       }
    }

and heres my = operator overloading

template <typename L>
    const List<L> List<L>::operator=(const List<L>& another)
    {
       Node<L>* temp = another.first;
       temp->next=another.first->next;
       while (temp != another.last)
       {
          pushBack (temp->data);
          temp=temp->next;
       }
       pushBack (temp->data);
       return *this;
    }

i get no errors, except with the loading file, but thats a whole nother problem entirely. =) if you do see anything wrong however, lemme knnow =) thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.