Is any variable or container in c which contain more than one data type

sorry but My previous thread does not take any reply therefore i start new thread for prev topic.

struct, class both declare data type at compile time but in my case it will declare at run time according coming input e.g

blue print of coming input

1 time :- int, string
2 time :- string, string, string
3 time :- int, date, date, string
4 time :- date
so on.......

then how will i solve, all are for c++
There is no simple solution to this. Sorry.
Well, you got a good tip in your previous thread:
http://cplusplus.com/forum/beginner/43027/

A simple way to implement this using polymorphism
would look like this -> http://codepad.org/FKqK7FwH

A more advanced technique, which combines templates and polymorphism,
can be seen here -> http://www.cplusplus.com/forum/articles/18756/

An example using that technique can be seen here:
http://www.cplusplus.com/forum/general/33247/

Finally, if you're lazy, there's...

boost::any -> http://www.boost.org/doc/libs/1_46_1/doc/html/any.html and...
boost::variant -> http://www.boost.org/doc/libs/1_46_1/doc/html/variant.html
Last edited on
Topic archived. No new replies allowed.