Category : abstract-class

I have an abstract class as follows: class AbstractClass : public std::enable_shared_from_this<AbstractClass> { public: virtual ~AbstractClass() = default; virtual bool Start() = 0; virtual void Stop() = 0; }; This is the derived class: class DerivedClass : public AbstractClass { public: bool Start() override; void Stop() override; } I am trying to create an object ..

Read more

I have an Event system in which a Manager class contains a queue of Events. The Event class is currently an abstract base class from which all specific events are derived. The idea is to allow the Manager to process() specific events that are specialized classes constructed with their own, unique parameters elsewhere in the ..

Read more

I have declared the following classes in a header file (Environment.h) and I would like to make the superclass FieldAccessor abstract: I have declared the following classes in a header file (Environment.h) and I would like to make the superclass FieldAccessor abstract: #include <jni.h> #include <stdlib.h> #include <vector> class FieldAccessor { public: FieldAccessor( JNIEnv* env ..

Read more

I’m having a rough time with a particular C++ inheritance problem. Apologies if it got answered before, but I just couldn’t find a proper answer. Say we have two abstract classes, one using the other as argument type for one of the pure virtual functions: class Food { public: int calories=0; virtual void set_calories(int cal)=0; ..

Read more

Here’s my abstract class Storestate.h: #ifndef STORESTATE_H_ #define STORESTATE_H_ class Store; class StoreState { public: virtual void Close(Store&); virtual void Open(Store&); virtual void Sell(Store&); }; #endif The Derived class header file ConcreteStateOpened.h: #ifndef CONCRETESTATEOPENED_H_ #define CONCRETESTATEOPENED_H_ #include "StoreState.h" #include "Store.h" class ConcreteStateOpened : public StoreState { public: ConcreteStateOpened() {} void Open(Store&) override; void Close(Store&) override; ..

Read more