Reputation: 13
So I'm working on an interface that has a factory method which is extern C and a release abstract method.
I want to prevent calling delete directly through a pointer to base but to use the release method instead.
The Interface:
class IMyInterface {
public:
virtual void release() = 0;
protected:
~IMyInterface() = default;
};
Derived:
class MyConcreteImplementation final : public IMyInterface {
public:
void release() override {
delete this;
}
protected:
~MyConcreteImplementation(){
// Custom cleanup code //
}
};
The factory method:
extern "C" IMyInterface* createMyInterface() {
return new MyConcreteImplementation();
}
I was wondering about the following:
Thanks!
Upvotes: 1
Views: 86