I want to implement a base class with multiple children.
Base Class
template <typename T>
class Trigger
{
protected:
T threshold;
Trigger(T a_threshold) : threshold(std::pow(10, a_threshold / 20)){};
public:
void setThreshold(T a_threshold)
{
threshold = std::pow(10, a_threshold / 20);
}
virtual bool operator()(const T &first, const T &second) const;
virtual ~Trigger() = default;
};
Derived Class
template <typename T>
class ZeroCrossingRisingTrigger : public Trigger<T>
{
public:
ZeroCrossingRisingTrigger(void) : Trigger<T>(0.){};
bool operator()(const T &first, const T &second) const override
{
return (first <= 0) & (second > 0);
}
};
Usage in the main file
#include "Trigger.hpp"
int main([[maybe_unused]] int argc, [[maybe_unused]] char const *argv[])
{
Trigger::ZeroCrossingRisingTrigger<double> trig;
return 0;
}
But on I get the following error when I try to compile it:
(...): undefined reference to `Trigger::Trigger::operator()(double const&, double const&) const'
I don't understand why I get this error because I implemented the operator exactly as written in the error message.