I get this error message while I'm trying to use copy constructor, I understand why the error message is showing but I don't know how to resolve it.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <ctime>
#include <cmath>
#include <vector>
#include <cassert>
using namespace std;

class Error{
private:
    string err;
public:
    Error(string s){err = s;}
    string get() const{return err;}
};

class QueueFull:public Error{
public:
    QueueFull(string e):Error(e){}
};

class QueueEmpty:public Error{
public:
    QueueEmpty(string e):Error(e){}
};

template<typename Object>
class SingleList{
protected:
    class Node;
    typedef Node* NodePtr;
private:
    NodePtr last;
    NodePtr first;
    int sz;
    void free();
    void copy(const SingleList<Object>& s);
public:
    class Iterator;
    SingleList(){sz=0;last=NULL;first=NULL;}
    ~SingleList();
    SingleList(const SingleList<Object>& s);
    SingleList<Object>& operator=(const SingleList<Object>& s);
    void push(Object a);
    void pop()throw (QueueEmpty);
    int size() const{return sz;}
    Iterator begin();
    Iterator end();

};

template<typename Object>
class SingleList<Object>::Node{
private:
    Object element;
    NodePtr next;
    friend class SingleList<Object>;
    friend class SingleList<Object>::Iterator;
public:
    Node(const Object& e = Object(),Node* n = NULL):element(e),next(n){}
};

template<typename Object>
class SingleList<Object>::Iterator{
private:
    NodePtr pos;
    NodePtr last;
public:
    Iterator(){pos=NULL;last=NULL;}
    Object operator*() const;
    void operator++(int dummy);
    bool operator==(Iterator i)const;
    bool operator!=(Iterator i)const;
    friend class SingleList<Object>;
};

template<typename Object>
Object SingleList<Object>::Iterator::operator*() const
{
    assert(pos !=NULL);
    return pos->element;
}


template<typename Object>
void SingleList<Object>::Iterator::operator++(int dummy)
{
    assert(pos != NULL);
    pos = pos->next;
}

template<typename Object>
bool SingleList<Object>::Iterator::operator==(Iterator i) const
{
    return pos == i.pos;
}

template<typename Object>
bool SingleList<Object>::Iterator::operator!=(Iterator i) const
{
    return pos != i.pos;
}


template<typename Object>
typename SingleList<Object>::Iterator SingleList<Object>::begin()
{
    Iterator iter;
    iter.pos = first;
    iter.last = last;
    return iter;
}



template<typename Object>
typename SingleList<Object>::Iterator SingleList<Object>::end()
{
    Iterator iter;
    iter.pos = NULL;
    iter.last = last;
    return iter;
}



template<typename Object>
void SingleList<Object>::copy(const SingleList<Object>& s)
{
    for(    Iterator pos = s.begin();pos != s.end();pos++)
        push(*pos);
}

template<typename Object>
void SingleList<Object>::free()
{
 while(sz != 0)
     pop();
}

template<typename Object>
SingleList<Object>::~SingleList()
{
    free();
}

template<typename Object>
SingleList<Object>::SingleList(const SingleList<Object>& s)
{
    first = NULL;
    last = NULL;
    copy(s);
}

template<typename Object>
SingleList<Object>& SingleList<Object>::operator =(const SingleList<Object>& s)
{
    free();
    copy(s);
    return *this;
}

template<typename Object>
void SingleList<Object>::push(Object a)
{
    Node* n = new Node(a);
    if (last == NULL)
    {
        last = n;
        first = n;
    }
    else
    {
        last->next = n;
        last = n;
        last->next = NULL;
    }
    sz++;
}

template<typename Object>
void SingleList<Object>::pop()
{
    if (size() == 0)
        throw QueueEmpty("Empty Queue.\n");
    else
    {
        Node* del = first;
        first = first->next;
        delete del;
        sz--;
    }

}

int main()
{
    int j = 0;
    while(j == 0)
    {
    SingleList<int> l;
    SingleList<int> b(l);
    l.push(1);
    l.push(2);
    l.push(3);
    //cout << l.size();
    SingleList<int>::Iterator iter;
    iter = l.begin();
    for(;iter != l.end();iter++ )
        cout << *iter;
    j++;
    }

    return 0;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

why do you bother sending this stupid links if you dont have any answer dont reply to this thread.
and i guess you didnt read smart answering thread.

Comments
How about you not be an ass-clown
One day you will understand

why do you bother sending this stupid links if you dont have any answer dont reply to this thread.
and i guess you didnt read smart answering thread.

You present a lots of garbage unformatted code, can't explain your problem and now post so defiant message on the 100% correct Freaky_Chris's remarks...
What's a staggering impudence!..

yes i know that code is too big but i already said that the error is in copy constructor so i guess that you can easily scroll to that line... but while you were try to criticize my first thread you can be constructive and maybe try to help... is this forum for helping people or criticize... but i already find a mistake so thanks for nothing....

I find it interesting how When one person comments you can be so blunt and rude, yet when others side with him you are no long quite so rude. No doubt because you realised you were in the wrong.

This article has been dead for over six months. Start a new discussion instead.