I need help pls :(

This is a discussion on I need help pls :( within the C++ Programming forums, part of the General Programming Boards category; Hi,,, i'm new here and i have a homework and really don't know how to solve it... i'm trying my ...

  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 05: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, 07:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 02:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 09:46 AM
  4. C programming - pls pls help me
    By sally arnold in forum C Programming
    Replies: 10
    Last Post: 01-16-2002, 03: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

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