last night my question on vector pairing was answered :)
However, I have a new problem. In my case, I have a toString() method declared in my class as follows.
string toString() {
stringstream info;
info << "Name : " << getName() << "\nSubject: " << getSubject() << "\nResult : " << getGrade() << endl << endl;
return info.str();
}
Next, I have a vector and printing code as follow:
vector<pair<Student*, string>> Students;
//...
Students.push_back(make_pair(Abbie, Abbie->getGrade(80)));
//...
for (int i = 0; i < Students.size(); i++)
{
cout << Students[i]->toString() << endl;
}
Apparently the grade is not being captured, and is not being printed.
Am I not supposed to cout this way if I have a toString()? If it is not, may I know how am I suppose to do it?
Anyone can help? :)
Edit: I have found my source of error - I assigned values using '==' instead of '='. But nevertheless, thank you all for trying to help