m@j3R ; said:
I need to use sth. like container for different types of variables.
Is sth like this in c++ STL?
----|----------|--|----|------|etc.
var1| var2 |v3|var4| var5 |etc.
int | float |bo|int | char |etc.
In C++, make a base abstract class Var. Now make classes Int, Float, etc
derived from it. Your container will be a std::deque<Var*>, or to make it
more easily memory safe std::deque<boost::shared_ptr<Var>>. Feel free to
add whatever pure virtual functions you want to class Var. You could make
your hierarchy more elaborate too, such as creating a class Float8 derived
from Float, Float16, etc.
You can use boost::any, as suggested in the other post. Looking at the
code, it seems the same as the above idea, except you don't have to create
class Var, Int, Float etc. So it should suffice in most circumstances.
Another thing is that one can think of std:
stringstream as a container of
heterogenous types.
std:
stringstream container;
container << intVal << ' ' << floatVal << ' ' << charVal << ' ' << boolVal;