If you just want whitespace-delimited "words" (or tokens or what you want to call them) from a string, there is some functionality in C++ that can do it for you very simply:
string buf = "PiCalculator(RandGen *randGen, int nPoints) : randGen(randGen), nPoints(nPoints) {";
std::istringstream iss(buf);
std::vector<std::string> tokens;
std::copy(std::istream_iterator<std::string>(iss),
std::istream_iterator<std::string>(),
std::back_inserter(tokens));
The above code will copy all (whitespace delimited) "tokens" from the string buf
to the vector tokens
.
References: