I have created a generic array-like template to create arrays of different types. Now I need to get user input from a menu about which type of array they are building. I tried having the user enter a number and using that number to pick a string from an array of constant strings. But pretty obviously, that threw a type conversion error. Is there a way to convert the literal string of a type into it's type or refer to a type directly. Thanks!
Here is the code I need to fit a type into at runtime:
SimpleVector<TYPE> myVect = SimpleVector<TYPE>(dataSize);
I also tried this switch statement which I would like better but I am getting a redefinition error.
switch (dataChoice) {
case 1:
SimpleVector<int> myVect = SimpleVector<int>(dataSize);
break;
case 2:
SimpleVector<double> myVect = SimpleVector<double>(dataSize);
break;
case 3:
SimpleVector<string> myVect = SimpleVector<string>(dataSize);
break;
default:
break;
}