I am trying to create an inherited class GraduateStudent of the class Student with a method that returns the tuition_fees+library_fines (this latter is private and we get access to it via Get and Set functions that are public in the parent class). I get the following message: "a missing vtable usually means the first non-inline virtual member function has no definition." Which proves that there's a virtual function that cannot be implemented. Here's my header, implementation and main codes, I cannot spot my mistake. Any suggestions to fix that ? Thank you !
#include "Student.hpp"
class GraduateStudent : public Student {
private:
double library_fines;
public:
GraduateStudent();
GraduateStudent(std::string name, double fines, double fees, bool fullTime);
bool fullTime;
virtual double MoneyOwed() const;
virtual ~GraduateStudent() {} ;
};
#include "GraduateStudent.hpp"
#include "Student.hpp"
#include <iostream>
GraduateStudent::GraduateStudent() : Student()
{
bool fullTime;
}
double GraduateStudent::MoneyOwed() const
{
return tuition_fees + GetLibraryFines();
}
int main(int argc, char* argv[])
{
Student* stu1= new GraduateStudent;
Student* stu2= new GraduateStudent;
//computing the owes
stu1->tuition_fees= 1000.0;
stu1->SetLibraryFines(10);
stu2->SetLibraryFines(1500);
stu2->tuition_fees= 1000.0;
std::cout << "Fees for Student 1=" << stu1-> MoneyOwed()<<"\n";
std::cout << "Fees for Student 2=" << stu2-> MoneyOwed()<<"\n";
delete stu1;
delete stu2;
return 0;
}
When I test for the parent class, everything works perfectly. But I prefer sharing the header of the parent class here:
#include <string>
#include <iostream>
class Student {
public:
Student();
Student(std::string name, double fines, double fees);
std::string name;
double tuition_fees;
virtual double MoneyOwed() const;
virtual ~Student() {};
void SetLibraryFines(double amount);
double GetLibraryFines() const;
friend std::ostream& operator<<(std::ostream& out, Student const& obj);
private:
double library_fines;
};