This is the way that came to mind, but the first vector (iv) is for some reason empty.
#include <string> #include <vector> typedef std::vector<std::string> stringVector; typedef std::vector<int> intVector; intVector & StringVectorToIntVector(const stringVector strv){ intVector iv; for (int i = 0; i < strv.size(); i++) iv.push_back(atoi(strv[i].c_str())); return iv; } #include <iostream> using namespace std; int main(){ stringVector v; intVector iv; v.push_back("10"); v.push_back("15"); v.push_back("20"); iv = StringVectorToIntVector(v); return 0; }