Thread: About Queues

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    About Queues

    Hi,

    I am making a class for Queue program and wanted to ask something.

    I have made a class as:
    -------------------------------------------------------------------------
    Code:
    #include<iostream>
    
     using namespace std;
     
     
     class NodeCustomer
     {
     public:
     
     NodeCustomer();//default constructor for the node/
        
     
     //getter and setter methods for time/
     int gettime();
     void settime(); 
     
     //getter and setter methods for the next pointer/
     int getNext(); 
     void setNext(); 
        
     ~NodeCustomer();//default destructor for the node/
     
     
     private:   
        
        int time;    //variable for time/
        node *nextptr; //next pointer for node/    
        int node;// variablenode for customer/  
        
    };       
            
    main()
    {
     void enqueue(int node)
     {
     
      Node* newNode=new Node(); // creating new node/  
     rear = rear+1
     
     
     rear = node
     
    }
     
     
          
    }
    system("pause");      
    }
    ----------------------------------------------------------------------
    We can define a queue with a fix size in array but how can we define a queue with a changing size in link list?

    regards,
    Last edited by student111; 11-23-2013 at 05:34 AM. Reason: correcting

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    There are many tutorials and guides to creating linked lists.

    In C++ I'd save myself the hassle and use a container, like queue - C++ Reference
    These grow dynamically in size without you having to write a linked list implementation. Is there a reason you want to write your own? I've slaved through a lot of manual dynamic memory allocation in C and am finally an STL convert.

    If you used STL you could use the same class for fixed size and changing size queues, since currently putting that class in an array is strange, since it has a next pointer. Unless you pointed all the next pointers to the next element of the array. No, that's still odd.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help with Queues
    By Hikaru90 in forum C Programming
    Replies: 5
    Last Post: 03-14-2010, 08:55 AM
  2. queues
    By rebelfirst in forum C++ Programming
    Replies: 9
    Last Post: 12-02-2007, 05:33 AM
  3. Regarding queues!!
    By coolkarthik20 in forum C Programming
    Replies: 2
    Last Post: 06-13-2007, 05:08 AM
  4. Queues
    By ramayana in forum C Programming
    Replies: 22
    Last Post: 01-01-2006, 02:08 AM
  5. queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-11-2001, 05:19 PM