I am currently working on a lab assignment and when running the program, I get multiple weird characters within it. Is there something that I am missing or doing wrong? I know I am not so sure about the boolan functions to compare in student.cpp. Thank you.
#include "student.h"
//implement the required 3 functions here
Student::Student(constchar initId[], double gpa)
{
// initialize a newly created student object with the passed in value
cout << "Id: " << initId << " GPA: " << gpa << endl;
}
bool Student::isLessThanByID(const Student& aStudent) const
{
// compare the current student object with the passed in one by id.
if (strcmp(id, aStudent.id) > 0)
{
returntrue;
}
else
{
returnfalse;
}
}
bool Student::isLessThanByGpa(const Student& aStudent) const
{
// compare the current student object with the passed in one by gpa
if (gpa < aStudent.gpa)
{
returntrue;
}
else
{
returnfalse;
}
}
void Student::print() const
{
cout << id << '\t' << gpa << endl;
}
I see, in the void Student::print() const section. For initialization it looks I have to do so in the Student::Student section. To get it to talk, would a pointer be better? (That's what we are learning about, so I assume so,but I don't want to assume). I cannot edit the print() section as I have to implement using the other sections.
Hopefully this makes sense. Still learning here and trying to get help without getting the answers.