I want simulated interface sterotype in C++ using abstract class. But in Eclipse IDE I get "Multiple markers at this line - The type 'Handler' must implement the inherited pure virtual method 'Handler::setNext'"
My question is Why this?.
Handler.h
class Handler {
public:
virtual void setNext(Handler &next) = 0;
Handler();
virtual ~Handler();
virtual void process() = 0;
public:
Handler *nextInChain;
};
Handler.cpp
#include "Handler.h"
Handler::Handler(){
}
Handler::~Handler(){
}
Oracle.h
#include "Handler.h"
class Oracle : virtual public Handler {
public:
Oracle();
virtual ~Oracle();
virtual void process();
virtual void setNext(Handler &next);
private:
};
Oracle.cpp
#include "Oracle.h"
Oracle::Oracle(){
Handler AQUI;//AQUI I get Multiple markers at this line
//- The type 'Handler' must implement the inherited pure virtual method
//'Handler::setNext'
}
Oracle::~Oracle(){
}
void Oracle::process(){
}
void Oracle::setNext(Handler &next){
}
This is incorrect:
Handler AQUI;
You cannot instantiate an abstract class.
What you want to do is define a pointer to Handler
and assign it the address of a valid object from a child class, like Oracle
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With