One string into multiple variables

I'm working with classes and i have this little problem
the constructor is based on (string, int, enum, enum)


this is main
1
2
  Pokemon timburr("Timburr, #532, Fighting,");
  assert(timburr.get_name() == "Timburr");


this is defention cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
Pokemon::Pokemon(string name, int ndex, Type type1, Type type2)
{
	this->name = name;
	this->ndex = ndex;
	this->type1 = type1;
	this->type2 = type2;
	
}

string Pokemon::get_name() {
	return name;
}




I know i have to use substr and the find, but i cant seperate the name number and the type... could any one get me started?

i tried using this but it wont work
1
2
3
string Pokemon::get_name() {
        return name.substr(0, name.find(","));
}




The constructor for Pokemon takes four parameters. "Timburr, #532, Fighting," is only a single value, a string of characters. The compiler doesn't know how to interpret this as four values. You have to pass the values as the function expects them:
 
Pokemon timburr("Timburr", 532, Fighting, /*I don't what goes here*/);
Topic archived. No new replies allowed.