-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inherited/non-inherited constructor and destructor #8
Comments
The example is correct. And it's a good question, I can see that it may be unclear. Thank you! I'll think how to nicely express it in the book. For now, a quick reply: "inherited" means that you call a method of an ancestor. If doesn't matter whether it's a virtual method or not. "override" is only useful when you override a virtual method of an ancestor. When an ancestor has a virtual method The "Destroy" is virtual at TObject, so you always want to override it in descendants. This way the In contrast, there is no virtual constructor in TObject. So you have nothing to override. Note that this is true because TPlayer descends from |
And how it's different from constructors See #8
To explain this correctly, this topic deserved a three new sections in the book :)
I hope that these are informative :) |
In the example:
We don't have override for
constructor Create;
but still we callinherited;
- is this correct? Maybe an additional note would be nice on whydestructor
must beoverride
and must haveinherited;
but the constructor doesn't seem to need those?The text was updated successfully, but these errors were encountered: