I am very used to Java where I can create an ArrayList to hold multiple objects, but I don’t know how to do it in C++.
I have 6 different objects:
WebcamData
UltrasonicData
KinectData
ImuData
GpsData
SickData
I need to hold an instance of each in one array.
In java it would be like:
ArrayList array = new ArrayList();
array.add(new WebcamData);
array.add(new UltrasonicData);
etc…
How can I make a similar array in C++?
Thank you
Use
std::vector<boost::any>:Read the documentation:
The implementation of
boost::anyis very simple, which means you can implement it yourself if you cannot use Boost library.A good topic at Stackoverflow: