-2

Why do I keep getting an error on compile with this code?

#ifndef OPERATOR_H
#define OPERATOR_H
#include <cstdlib>
#include <iostream>
#include <string>
#include "Individual.h"

using namespace std;

class Operator
{
public:
Operator();

virtual void execute (Individual* parent);

private:

};
#endif

Then in the cpp file I have

#include <cstdlib>
#include <iostream>
#include <string>
#include "Operator.h"

using namespace std;

Operator::Operator()
{  

}

void execute(Individual* parent)
{    

}
Karthik T
  • 30,638
  • 5
  • 66
  • 86
user2661167
  • 441
  • 5
  • 13
  • 21

1 Answers1

0

Define a destructor. The vtable for a class with virtual methods is created in the translation unit that defines the constructor.

In your header, add:

virtual ~Operator();

And in your source file, add:

Operator::~Operator() {
}
Tyler McHenry
  • 72,029
  • 16
  • 119
  • 161