I am trying to set the type of a vector using a string at runtime. I can use an if else but wondering if there are better options
string typestr;
cin>>typeStr
if(typeStr=="int")
vector<int> sample;
else if(typeStr=="double")
vector<double> sample;
...
Aucun commentaire:
Enregistrer un commentaire