Hi,
I wish to place objects of class B and class C into one queue. The queue, say class Queue, is a class template. Further, B and C are derived from class A. Can I say something like:
Queue<A> qobject;
B bob;
C cat;
qobject.insert(bob);
qobject.insert(cat);
or do I have to cast objects of B and C to type A before insertion. If so how do I cast objects from one type to another at run time.
Also, if the above is possible how do I, when removing objects from the queue, know which type of object I am removing.
I would be grateful for all help
I wish to place objects of class B and class C into one queue. The queue, say class Queue, is a class template. Further, B and C are derived from class A. Can I say something like:
Queue<A> qobject;
B bob;
C cat;
qobject.insert(bob);
qobject.insert(cat);
or do I have to cast objects of B and C to type A before insertion. If so how do I cast objects from one type to another at run time.
Also, if the above is possible how do I, when removing objects from the queue, know which type of object I am removing.
I would be grateful for all help