Hi

i want to save similar objects, meaning having same superclass, in an array. Example: I have a superclass vehicle. Class car and truck inherit from vehicle. Now i have a few from both of them an want to put them in an array, vector, set or else. Is this possible in C++ or are there an workarounds? When i remember right, Java and C# offer this feature.


Here again an example:
Code:
class vehicle{
  int mMaxSpeed;
}
class truck : public vehicle{
  int mTrailerLength;
}
class car : public vehicle{
  bool mHasHitch;
}

main()
{
  truck mytruck = new truck();
  car mycar = new car();

  vector<vehicle> myCarPool;
  myCarPool.pushback(mytruck);
  myCarPool.pushback(mycar);
}
Greets