I have a program that needs to set the type of a vector as the program is executed (according to a value in a configuration file).
I have tried this:
int a = 1
if(a == 1) vector<int> test(6);
else vector<unsigned int> test(6);
test.push_back(3);
But this gives me:
Error 1 error C2065: 'test' : undeclared identifier
I'm not entirely sure why, but I think this is because the vector is not actually decided at compile time so the compiler cannot work with it whilst compiling the rest of the code.
Is there a way to decide the type of a vector at runtime similar to what I have attempted above? I have tried to create one version outside the if and then delete it and re-write the new version inside the IF. This however feels wrong and I can't get it to work anyway. thanks.