On Wednesday, 10 April 2013 at 06:03:08 UTC, Manu wrote:
[...]
I do use virtual functions, that's the point of classes. But most functions
are not virtual. More-so, most functions are trivial accessors, which
really shouldn't be virtual.
OOP by design recommends liberal use of accessors, ie, properties, that
usually just set or return a variable. Wen would you ever want @property
size_t size() { return size; } to be a virtual call?
Yes, if you want to change its behavior in a derived class.
One nice feature of properties is that you can trigger actions when assigning/reading from properties.
This is very used in OO GUI and DB code in other languages.
I have lots of code from JVM and .NET languages with such examples.Can you demonstrate a high level class, ie, not a primitive tool, but the
sort of thing a programmer would write in their daily work where all/most
functions would be virtual?
OO code in the enterprise world is a beauty in itself, regardless of the language.