[Linker error] undefined reference to `vtable for OBJECT

Hey all,
I'm having a problem that i simply cannot fix.

here is my code:
StaffMember.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef StaffMember_H
#define StaffMember_H
#include <string>
using namespace std;
class StaffMember
{
      public:
             int id;
             string name;
             virtual double wage() = 0;
             
};
#endif


Manager.h
1
2
3
4
5
6
7
8
9
10
11
#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 function virtual double wage() = 0; which makes StaffMember an abstract class.
Last edited on
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.
redefined the wage() function for the derived classes


how do i go about doing that? i don't think i have.
Topic archived. No new replies allowed.