I want a function that creates an array for testing purposes:
The simple answer is that you cannot, because data types need to be specifically declared at compile time.
If you can use boost libraries,
boost::variant vec;
can suit your needs.
You cannot use union
because std::vector
is not a POD (Plain Old Datatype).
EDIT:
As @Rob pointed out:
Void pointers need to be converted into a pointer to something else - at compile time - before they can be used that way. So the answer is still "cannot" use void pointers to make a variable data type.