c++ - Changing value of a class outside the class -


i have class team has attribute "points". in sheet.cpp want change points function this:

void result(team a, team b)     { int startwerte[] = { 8, 8 };//just random start values)  std::vector< int > punkte(startwerte, startwerte + sizeof(startwerte) / sizeof(int)); points[0]=a.getpoints(); points[1]=b.getpoints(); 

here follows calculation ends in final values points stored in points2. want set them points of teams, stored.

a.setpoints(points[0]) b.setpoints(points[1]); 

they correct values, whenever function ends values not stored in team.points correctly. if letting result function return points2 vector lets vector testvector in int main() works. example

vector<int> testvector; testvector =result(teama, teamb) {//same code before follows teama.setpoints(testvector[0]; teamb.setpoints(testvector[1]; 

if repeat result-function everythin stored correct. there no way store value points of team class outside int main ()?

i think problem passing team value rather reference.

change result method to

void result(team & a, team & b) 

and should fine.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -