I hope someone with broad knowledge about templates and arrays can direct me on this.
i know how to make a simple template class and use it for different datatypes. i have little knowledge about vector-containers. my question is if it can be possible to have a "container" (im not sure if it is the right definition to use) that stores different datatypes in one array?
if you dont get it i will try make some C++/pseudo-code thing so its easier to understand what im looking for:
the class of container:Code:
container->AddThing<myDataType> (MyDataType(100, 50));
so the array should be able to store chars, ints, etc, and also own datatypes(structures). for example on the example above the memory-layout or array would look like this (if it really matters):Code:
//has a vector?
std::vector<SomeClass*> array; //here there must be stored different datatypes
template <class T> void AddThing(T value)
array = 100;
array[0+4] = 4000;
array[0+4+DataTypeSize] = 100 and 50;
the memory layout is really not that important for me before I get something to work, i am really just out after storing a template (different datatypes) into an array, so i can easilly access the members with the dot or pointer operator, or by using an iterator.
i need some direction, or what to look for to find the right documentation i can read to learn this, if C++ are able to do this?
(edit: also you see i have SomeClass as the parameter in the vector member, i wonder if SomeClass should be a pure virtual class or something. i am still not a pro in understanding pure virtual classes or functions and if this will be the best way to do it, if its even possible?)