How to implement a static function in an abstract class?? Where do I implement this?
class Item{
public:
//
// Enable (or disable) debug descriptions. When enabled, the String produced
// by descrip() includes the minimum width and maximum weight of the Item.
// Initially, debugging is disabled.
static enableDebug(bool);
};
First of all, that function needs a return type. I'll assume it's supposed to be void.
You implement it in a source file, just as you would implement any other method:
void Item::enableDebug(bool toggle)
{
// Do whatever
}
There's nothing special about it being static or the Item class being abstract. The only difference is that you do not have access to a this pointer (and consequently also not to member variables) within the method.
Static functions cannot be virtual so you implement it in the context of the class itself. It doesn't matter if the class is abstract or not.
void Item::enableDebug(bool)
{
}
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