This
MyHash::MyHash()
{
for(int i = 0; i < 100; i++)
{
students[i].id.assign(NULL);
students[i].name.assign(NULL);
}
}
is incorrect. This is correct
MyHash::MyHash()
{
}
You don't have to 'assign NULL' to std::string
. The default constructor for std::string
automatically creates an empty string. In fact assigning NULL to a std::string is an error because this method always expects a pointer to a C string.
In fact you don't need a MyHash
constructor at all, because the default one does everything you were trying to do in the version you wrote. You see C++ is easier than you think.