![]() |
|
#1
|
|||
|
|||
help with stl vector of non-homogenous derived objectshi
I need to fill a stl vector with different derived class objects.Thats what I want to acheive with my implementation. Hence I'm using polymorphism so that I can create a vector of base class pointers and then use that vector to create new objects of derived classes. Please let me know if there are any issues with my implementation. CPP / C++ / C Code:
regards kiran Last edited by LuciWiz : 13-Jan-2007 at 06:02.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#2
|
|||
|
|||
Re: help with stl vector of non-homogenous derived objectsThey're not "non-homogenous" (the word you're looking for is heterogenous) if they all derive from something else so that they share a common base. Otherwise, there is no practical way to store heterogenous objects in a vector. When we initialize a vector, we specify the typename of the type that it will store. It isn't as if we're likely to get away from that "protocol" any time soon.
:davis: |
|
#3
|
|||
|
|||
Re: help with stl vector of non-homogenous derived objectshi
yes..you are right...actually iam new to stl stuff so i did not know how to frame the question...i just wanted to emphasize that the objects that are referred by the vector of base class pointers are different(heterogenous)... but does the implementation looks correct to you ?? thanks kiran |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| References to base class to access derived class only members | mirizar | C++ Forum | 3 | 03-Dec-2005 20:40 |
| controling dialog objects & multiple source files | omills | MS Visual C++ / MFC Forum | 0 | 14-Jul-2004 23:30 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The