Re: extending Gdk::Region

Am Donnerstag, den 07.05.2009, 13:24 -0400 schrieb Christopher Harvey:
> You used the term "Value Semantics" a lot in the last e-mail. What are
> value semantics?

Sorry, I should have been clearer.  It's an ad hoc shorthand for
"value-type semantics", or "copy-by-value semantics".  The established
term "value type" should yield appropriate search results.

Since polymorphism requires both reference semantics and virtual methods
to override, this central OOP concept is not applicable to Gdk::Region.
Making the destructor virtual would help with one case only:  A class
derived from Gdk::Region is instantiated on the heap, and delete is used
with a pointer to the base class.

Even if you decide to derive from Gdk::Region for convenience, I can't
see how it could be useful to allocate instances dynamically and then
access the instances through Gdk::Region& references.  Any functionality
you could possibly add to Gdk::Region would only be accessible through a
reference to your derived type.

It isn't technically wrong to write code like this, so it could be
argued that we should make the destructor virtual on the grounds of
completeness.  Gdk::Region objects are not dirt cheap enough to make
performance considerations a factor, so I personally wouldn't mind much.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]