Could you please tell me what is the closest data type in C++ to python list? If there is nothing similar, how would you build it in C++?
There is no real equivalent, and it would be extremely difficult to provide one. Python and C++ are radically different languages, and providing one really wouldn't make much sense in the context of C++. The most important differences are that everything in Python is dynamically allocated, and is an "object", and that Python uses duck typing.
FWIW: one very early library (before templates) in C++ did offer
containers of Object*
, with derived classes to box int
,
double
, etc. Actual experience showed very quickly that it
wasn't a good idea. (And I'm curious: does any one else
remember it? And particularly, exactly what it was
called---something with NHS in it, but I can't remember more.)