Thread: Queue and Objects

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Question Queue and Objects

    Can you enqueue and dequeue class objects?
    Say I want to make classes called processChangeConfig, processUpdateRecord, etc.
    Can I place an idividual instantiation of the diferent objects in a queue. Say during traversal of the queue the class member functions alter or prepare the class for the final processing by the servicing end of the queue? Sorry if that is some messed up logic. But I want the items passed through the que to be a class that is doing changes to the item up until the final processing by the servicing end of the queue.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    <queue> is part of the STL, Standard Template Library. So, you can put whatever class of objects you like into the container. Just make sure you create a copy constructor and overload the assignment operator for your classes.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Originally posted by joshdick
    Just make sure you create a copy constructor and overload the assignment operator for your classes.
    I'm sure xviddivxoggmp3 will have a very good copy constructor and operator= (assignment operator) real soon.

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    I'm I missing a joke here, jlou?
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Originally posted by joshdick
    I'm I missing a joke here, jlou?
    xviddivxoggmp3 has had a couple threads now working on a linklist class where the major problem is getting the copy constructor and operator= to work correctly. So hopefully once that is solved he or she will be comfortable making them.

  6. #6
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    speaking of the copy constructor and overloaded =.
    It still doesn't work after converting to & and using the . dot operator to access the data. it crashes at the same location.
    I do not have anything but an access error. I will be working on it again later tonight, so i will post more info and the revised code then. these are the threads that jlou is talking about.
    thread one and thread two
    Last edited by xviddivxoggmp3; 10-26-2003 at 09:44 PM.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Queue Problem
    By SMurf in forum C Programming
    Replies: 3
    Last Post: 04-26-2008, 11:30 AM
  3. stack and heap objects
    By John_L in forum C++ Programming
    Replies: 4
    Last Post: 03-18-2008, 10:20 AM
  4. Implementing of queue using objects?
    By Argo_Jeude in forum C++ Programming
    Replies: 5
    Last Post: 08-07-2007, 11:55 AM
  5. queue and objects
    By dleigh0 in forum C++ Programming
    Replies: 2
    Last Post: 11-11-2005, 06:42 PM