So I finished a project I've been working on for my C++ course in college, and I've run into an error I haven't seen before. I googled the code (0xC0000374) and apparently its related to heap corruption.. I then understood this is much above my head
I have dynamically allocated memory, but I did delete all memory that was allocated at the end of my program. Here is the relevant code:
main.cpp
// create a roster class instance with 5 student objects
Roster *classRoster = new Roster(5);
then calls
roster.cpp
// constructor
Roster::Roster(int class_size) {
this->classSize = class_size;
this->index = 0;
for (int i = 0; i < this->classSize; i++) {
this->classRosterArray[i] = new Student;
}
}
I then call various getters/setters and member functions that do not handle memory allocation. This is my destructor.
// deallocate memory that was dynamically allocated
Roster::~Roster() {
for (int i = 0; i < this->classSize; i++) {
delete this->classRosterArray[i];
}
}
Which is called at the end of main.cpp
// call destructor and clean allocated memory
classRoster->~Roster();
delete classRoster;
return 0;
What have I missed here? All output from the program is normal, only the exit code is incorrect.