The cout statement in this for loop:
for (vector<Student>::iterator qw = students.begin(); qw != students.end(); ++qw){
Student a = *qw;
name = a.getName();
regno = a.getRegNo();
std::cout << "Name: "<< name << " Reg Number: " << regno << endl;
}
Is creating some odd behavior, what the cout should print is something like this:
Name: Mike Sanderson Reg Number: 10101
However which it actually prints out it:
Reg Number: 10101on
It would seem to me that after the second part of the cout statement it is going back to the start of the line and overwriting itself, but why? Hope you guys can help me and if you need more info let me know!
Student
wouldn't happen to have a pointer in it that is allocated dynamic memory while not following the rule of three, would it? – Addieaddiegoname
? What doesa.getName()
return? (Put a debug breakpoint right before thecout
line and see what's inname
andregno
.) – Sold