0
Abstract class purpose
Can anyone explain with a basic example what the purpose is of declaring an abstract method in a superclass with no implementation when it is declared and implemented in a subclass that inherits the superclass...why is it even needed?.
3 Respuestas
+ 1
A class "Character" that is not meaningful by itself but gives basic variables like Health can be inherited by other classes to make complex characters that can be instanced. An abstract method could be a Move function that must be custom-made for each character.
0
Hi, thanks for the reply but that still doesn't explain the purpose....you type your method in the subclass with its own implementation which I get but that will work exactly the same whether or not you specify an empty abstract method in the superclass...do you follow....what is the difference between specifying the empty method and not specifying it at all?
0
so you example of the move function...why bother to write the empty move() method at all...youre going to have to declare it in the subclass anyway if you want to use is so what even is the point of it...can you give me an example of code that either benefits from the empty method...or doesn't work without it.