And that's not a joke!
Theoretically it should be as we have just described, but every compiler has its exceptions.
FreePascal and Delphi compilers share this behavior.
Look at the picture beside.
It shows the Message window on focus, with a highlighted warning: it says that we've constructed the TEmployee class with the abstract method CountSalary.
The message is warning us about the fact that an abstract class, which is so because of a single method declared as abstract, is instantiated into an object: and this contradicts everything we've written until now.
But again... FP compiler does this against a normal behavior we should expect from an OOP compiler.
How might we solve this little problem?
We have two possibilities:
- to modify the Lazarus options, to turn the simple warnings into errors;
- to use the interfaces.
The first one is not the best solution unless you have confidence with Lazarus and you know the consequences of these changes.
You can try at your own risk: nothing dangerous indeed.
Maybe the real problem will be the impossibility to compile a more complex project which could be compiled with warnings.
The second one is the interface, which will be the next article's argument.
We'll see the difference between it and the abstract modifier.
But now the next pages hosts the code of the three classes TEmployee, TManager and TWorker.