this is a piece of code from my program for a game of quiz...this class is supposed to manage the marks of a player. i am passing marks for a question depending on its correctness to the setscore function and i want it to keep on updating the value of m_score so that finally i can return it from the getscore function....with this piece of code i am getting some junk values being returned by the getscore function . can someone help me in figuring this out????
it is generating a random no and based on that goes to a file and asks questions out of the file..."marks" is being returned by the o_SciTech.showAnswer statement....
1 2 3 4 5 6 7 8 9
int Q_Rand = (rand()%(max-min + 1)) + min;
main_quesfname = o_SciTech.quesfilename();
main_ansfname = o_SciTech.ansfilename();
o_SciTech.showQuestion(Q_Rand,main_quesfname);
cout << "what is your answer a, b, c or d " << endl;
cin >> ans;
marks = o_SciTech.showAnswer(Q_Rand,ans,main_quesfname,main_ansfname);
player[main_playerno].setscore(marks);
cout << "score till now = " << player[main_playerno].getscore() << endl;
Try to create minimal sample case: code which compiles, have reproduceable bug you trying to eliminate and does not use any files. Then post it here or on ideone.