One container with different data types

Hi,could You help me:

I would like to make container like array or vector with variables of different types (say int, double, complex, etc). The problem is i dont know before what kind of type will be each element of this array, only amounts of them. So, as i understood it should be done in templates.

So it should look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
main()
{
  for()
  {
     SuperArray[i]=A_int;
     SuperArray[i+1]=A_double;
     SuperArray[i+2]=A_complex;
  }
}

template SuperArray()
{
// and here definition of template class what i`m asking
}


as i got, while assigning operation "typename" of A should go as a parameter for SuperArray definition.

Thank you in advance.
Last edited on
You should look up boost::any which is an implementation for a heterogeneous data type for STL containers.
Topic archived. No new replies allowed.