+ 2
c++ array of multiple data type
Anyone knows how to having an array with multiple data type inside of the array? example: in python, Javascript, etc we can: ItIsArray=[12, 0.5,"string"] But if in c++, we can't do the code below, right? int ItIsArray={12, 0.5,"string};// return error how to do it? Thanks.
3 Answers
+ 1
You cannot make multiple data type arrays in probably any language.
If there is not too much different data types then you can make tuples or your own structures.
+ 1
This is why I love JavaScript.arrays can have different data types
0
For a shortcut, you may try using arrays of custom defined unions or classes.