I am getting error NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for Algorithm2A"
. I suppose the problem in my base class I declared the function as pure virtual, and then in the header .h
of derived class I redeclared it, in order to be able to implement it in the implementation file .cpp
.
IAlgorithm2.h -- that is my abstract class
#include "IAlgorithm1.h"
//! Algorithm2 interface
class IAlgorithm2 {
public:
~IAlgorithm2() {
}
virtual std::vector<int> calculateLCP(std::string BWT)=0;
};
Now, I have the implementation of this in Algorithm2.h
, andAlgorithm2.cpp
.
Algorithm2A.hpp
class Algorithm2A : public IAlgorithm2 {
protected:
IAlgorithm1 &algorithm1;
std::vector<Interval> getIntervals(int i, int j) {
return algorithm1.getIntervals(i, j);
}
public:
Algorithm2A(IAlgorithm1 &a) : algorithm1(a) {
}
std::vector<int> calculateLCP(std::string BWT);
};
Algorithm2A.cpp
#include "Algorithm2A.hpp"
std::vector<int> Algorithm2A::calculateLCP(std::string BWT) {
// implementation of this
}
How should this be done? If I remove the definition from the Algorithm2A.h
that it won't compile, and if I leave it there, than there is a vtable problem.
edit: this is not a matter of templates
IAlgorithm1.h
//! Algorithm1 interface
class IAlgorithm1 {
protected:
virtual std::string uniqueCharsInInterval(int i, int j)=0;
public:
~IAlgorithm1() {
}
virtual std::vector<Interval> getIntervals(int i, int j)=0;
};
#endif /* Algorithm1_h */
Algorithm1A.h
#include "IAlgorithm1.h"
class Algorithm1A : public IAlgorithm1 {
protected:
IRank &rank;
OrderedAlphabet &alphabet;
std::map<symbol_type, occurence_type> &C;
std::string &BWT;
public:
Algorithm1A(IRank &r,
OrderedAlphabet &a,
std::map<symbol_type, occurence_type> &c,
std::string &bwt):
rank(r), alphabet(a), C(c), BWT(bwt) {
}
std::string uniqueCharsInInterval(int i, int j);
There is also an implementation file Algorithm1A.cpp