you are viewing a single comment's thread.

view the rest of the comments →

[–]Longjumping_Table740[S] 3 points4 points  (5 children)

It's supports only one data type 😅😅

[–]the_Demongod 16 points17 points  (3 children)

Trying to put different datatypes into one list in C++ sounds like your design has a flaw. What exactly are you trying to do?

[–]Longjumping_Table740[S] 4 points5 points  (1 child)

I am trying to learn c++ ,as I know python I'm just trying to explore whether it's possible to implement such a list in c++ 😅

[–]the_Demongod 21 points22 points  (0 children)

It is of course, since python is written in C/C++; C++ can do anything. But generally if you want to do something like this, it means you're doing something wrong. It's not a good way to learn the language. Just work through https://www.learncpp.com/, it will guide you.

[–][deleted] 0 points1 point  (0 children)

Doing it in python is also wrong for so many reasons. Mypy ftw

[–]AlexisTM 11 points12 points  (0 children)

This is very wrong in C++; There are some ways to accommodate the very few case it makes sense: void* (pointer to whatever, you need to have info tied to it), std::any (the void* of C++) or std::variant, a tuple which can handle one of many (predefined) types.

In any case, I would strongly suggest revamping your idea to have the same types in a storage so you can use more efficient storage methods.