There are a few problems with your code.
class Top{
Top();
virtual ~Top() = 0;
}
class access control defaults to private. This means that this class has a private constructor and thus cannot be constructed, nor can subclasses be constructed. A fixed version would probably look like:
class Top {
protected:
Top();
virtual ~Top() = 0;
}
The virtual destructor means you can't create a Top, but you could still create a subclass.
And as @Deduplicator pointed out, you still need a definition for Top::~Top() because subclasses' destructors will call it:
Top::~Top() {}
The declaration of class Bottom looks fine, though you don't need to repeat public:.
And one minor problem with both class definitions: you forgot the semicolon after the closing brace.
As for the implementation:
Top::Top(): Top() {}
The third Top is incorrect. That syntax is used to pass things to a superclass's constructor, or delegate to another constructor (of which you have none). Top is not its own superclass. The correct code is simply:
Top::Top() {}
Moving on...
Bottom::Bottom(char core){
core = core;
}
This has a problem because the parameter core hides the class member core. They need to be different names (though there is no requirement that the parameter name in a class declaration match the one in the method definition). I usually fix this by adding a trailing underscore to the parameter name:
Bottom::Bottom(char core_) {
core = core_;
}
Finally:
char Bottom::getCore(){
return core;
}
This is wrong because you declared it as a const method but this definition is not const. Fixed:
char Bottom::getCore() const {
return core;
}
BTW, you can have const and non-const versions of a method. Which one runs depends on if this is const or not.
One last thing: you forgot to define Bottom::~Bottom(). Add this:
Bottom::~Bottom() {
}
I've got a fixed version of this code, plus some token test code, posted online.
virtual ~Operator();?Bottom::Bottom(char core){core = core;}. Also if you have a question where you give two options, why won't you try it yourself. It's not like an hour of coding that would go in vain.