I would like to accept input "box 3 4 5" or
"triangle 10 10"
and recognize the first as a shape, then do calculations on the remaining numbers but I am having trouble assigning box to a string and the numbers to integers. Some tries result in error "cannot convert std::string to int"
I've written the raw code to read the values. But it looks like your heading towards writing a factory function that returns a shape read from a stream.
int main()
{
std::string coms;
std::getline(std::cin, coms);
std::istringstream iss(coms);
// we expect string, then an unspecified number of integers
std::string shape;
std::vector<int> params;
// read them
iss >> shape;
int param;
while (iss >> param)
{
params.push_back(param);
}
// do something with the values
}