Type Conversion in Overloaded Operator

Can someone please tell me another way to convert string to int in this segment of code? This way gives me an error. Just looking for another way to do this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
istream &operator>>(istream& in, MasterData& d)  \
{												\
		string value;	
		getline(in, d.playerId, ',');	
		getline(in, d.firstName, ',');
		getline(in, d.lastName, ',');
		getline(in, d.division, ',');
		getline(in, d.teamName, ',');

		  getline(in, value, ',');
		d.appearances = stoi(value);  
		
		getline(in, value, ',');
		d.atBats = stoi(value);

		getline(in, value, ',');
		d.singles = stoi(value);

		getline(in, value, ',');
		d.doubles = stoi(value);

		getline(in, value, ',');
		d.triples = stoi(value);

		getline(in, value, ',');
		d.homeRuns = stoi(value);

		getline(in, value, ',');
		d.sacFly = stoi(value);

		getline(in, value, ',');
		d.walks = stoi(value);

		getline(in, value, ',');
		d.hitByPitch = stoi(value);

		getline(in, value, ',');
		d.battingAvg = stod(value);  
		getline(in, value, ',');
		d.OBP = stod(value);

		getline(in, value, '\n');
		d.sluggingPercent = stod(value);
Last edited on
Topic archived. No new replies allowed.