Well, why are you even trying to make your own vectors and sort algorithms in the first place?
Why not just do something like:
Code:
#include <vector>
#include <algorithm>
/*...*/
void Demo() {
std::vector<Student> collection;
collection.reserve(25); // Reserve at least enough space for 25 students
for (int i = 0; i < 25; ++i){
collection.push_back(Student()); // Add a new student
collection[i].SetInfo(...); // and set its info
}
std::sort(collection.begin(),collection.end());
}
/* Note you need to provide "operator<" for class Student; this
will be needed to sort. No other operators are needed.*/
I haven't tried to compile it, so the code may be suspect, but it should be close. This code uses the C++ standard ways of doing these things, so it should work better than a homegrown solution.