lundi 29 mai 2017

Template class errors [on hold]

Hi i cant figure out the errors ................................................ ...............................................

    #include<iostream>
    using namespace std;
    template <class Tobj>
    class node{
        public:
            Tobj obj_add;
            node *next;
            //----------------
            bool isEmpty(node &head);
            char menu();
            void insertAsFist(node *&head,node *&last,Tobj objADD);
            void insert(node *&head,node *&last,Tobj objADD);
            void remove(node *&head,node *&last);
            void showlist(node *curret);
    };
    //---------------------
    //dEFINITIONS ARE:
    template <class Tobj>
    bool node<Tobj>::isEmpty(node &head){
        if(head==NULL)
        return true;
        else
        return false;
    }
    template <class Tobj>
            char node<Tobj>::menu(){
                char choice;
                cout<<"Menu.\n";
                cout<<"1. Add an item.\n";
                cout<<"2. Remove an item.\n";
                cout<<"3, Show the list.\n";
                cout<"4. Exit \n";
                cin>>choice;
                return choice;

            }
            template<class Tobj>
            void node<Tobj>::insertAsFist(node &head,node &last,Tobj 
&objADD){
                node *temp=new node;
                temp->obj_add=objADD;
                temp->next=NULL;
                head=temp;
                last=temp;
            }
            template<class Tobj>
            void node<Tobj>::insert(node &head,node &last,Tobj &objADD){
                if(isEmpty(head))
                insertAsFirstElement(head,last,number);
                else{
                    node *temp=new node;
                    temp->obj_add=NULL;
                    last->next=temp;
                    last=temp;
                }
            }
            template <class Tobj>
            void node<Tobj>::remove(node &head,node &last){
                if(isEmpty(head))
                cout<<"The list is already empty.\n";
                else if (head==last){
                    delete head;
                    head==NULL;
                    last==NULL;
                }
                else {
                    node *temp=head;
                    head=head->next;
                    delete temp;

                }
            }
            template <class Tobj>
            void node<Tobj>::showlist(node &curret){
                if(isEmpty(current))
                cout<<"The list is empty.\n";
                else {
                    cout<<"The list contains:\n";
                while (current!=NULL){
                    cout<<current->obj_add.Show()<<endl;
                    current=current->next;
                }
                }
            }

//----------------------------------

........................................................... ...........................................................

Aucun commentaire:

Enregistrer un commentaire