Thread: I need help pls :(

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    17

    Question I need help pls :(

    Hi,,, i'm new here and i have a homework and really don't know how to solve it... i'm trying my best but there no luck

    Please I need your help with node and singly linked list in C++...
    it is a homework:
    modify the list class by adding a member function for reversing the list:
    i need a reverse function
    void reverse ()

    and also add a new item at a special position:
    i need the function insert
    void insert (double x, int pos)

    pls help me


    Code:
    class Node{
    
        private:
    
        Node *head;
        Node *tail;
        Node *next;
        int info;
    
        public:
        bool IsEmpty ()
        {
            if (head==0)
            return true;
            else
            return false;
        }
        Node (int data, Node *ptr=0)
        {
            info=data;
            next=ptr;
        }
    
        void AddToHead (int data)
        {
            if (!IsEmpty ())
            {
                head= new Node (data);
                if (tail !=0)
                {
                    tail->next= new Node (data);
                    tail= tail->next;
                }
                else
                head= tail= new Node(data);
            }
        }
    
        void PrintAll(int data)
        {
            for (Node *temp=head; temp !=0; temp= temp->next)
            cout<< temp->info<<" ";
            cout<<endl;
        }
    
    /*    void Reverse ()
        {
            Node *p=head, *rev=0;
            while (!IsEmpty())
            {
                p= p->next;
                p->next = rev;
                rev = p;
    
                cout<< "The List as reversed: "<< p;
            }
            cout<< endl;
        }*/
    Last edited by ladybird__86; 11-05-2009 at 06:59 PM.

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    68
    Instead of immediately asking for someone to help you, make an effort and post your code. You will never learn if you do not attempt it first.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    17
    i'm trying to post the code but it doesn't work!!! i will try again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  4. C programming - pls pls help me
    By sally arnold in forum C Programming
    Replies: 10
    Last Post: 01-16-2002, 04:55 AM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM