c++ - Trouble with user defined data type in map -
goal : make map of student registrations via key, student number.
issue : seems reason when go add object map os crashes program.
structure of registration object:
private: std::string fname; std::string lname; long studentid; unsigned semester; vector<result> results; //user defined data structure, tested , works map declaration:
std::map<long, registration> studentregistrations; i use studentid in object key. test created registration object, set it's studentid , passed following method in class encapsulates map, called registrar.
void registrar::setregistration(registration& regist) { studentregistrations[regist.getstudentid()] = regist; //crashes here } my main:
int main() { registration regist; registrar r; regist.setstudentid(200); r.setregistration(regist); } program returns -1073741819 <0xc00000005> on windows. if in anyway helps.
Comments
Post a Comment