#ifndef Manager_H
#define Manager_H
#include "StaffMember.h"
class Manager: public StaffMember
{
public:
double salary;
double wage();
};
#endif
Casual.h
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef Casual_H
#define Casual_H
#include "StaffMember.h"
class Casual: public StaffMember
{
public:
int hours;
double rate;
double wage();
};
#endif
compiling produces the errors:
[Linker error] undefined reference to `vtable for Manager'
[Linker error] undefined reference to `vtable for StaffMember'
[Linker error] undefined reference to `vtable for Casual'
[Linker error] undefined reference to `vtable for Casual'
ld returned 1 exit status
C:\Dev-Cpp\Makefile.win [Build Error] [ITC140AST2.exe] Error 1
i've been looking all over the internet for solutions, but nothing seems to work. can anyone help me?
Cheers in advance.
I wouldn't have thought that header files would cause a linker error.
What are your cpp implementation files.
and have you redefined the wage() function for the derived classes, becuase in the base class StaffMember, it
is defined as a pure virtual functionvirtualdouble wage() = 0; which makes StaffMember an abstract class.
Hi... sorry to digress guys just a quick question. Does declaring a pure virtual function foo (thus making an abstract class) mean that all derived classes must have a function foo declared and defined?
Not strictly so.
If the derived class does not override the pure virtual function, then the derived class will also
be abstract.
If a derived class overrides the pure virtual function, then the derived class is a concrete class.