Re: "trivial" problem with template method pattern
"rogo" <d.rogowski@velian.de> wrote in message
news:1193912620.600033.314740@22g2000hsm.googlegroups.com...
Jim Langston schrieb:
A base class knows nothing of the
classes that derive from it. The derived classes know of the base class
they derive from.
That's not true. The declaration of "virtual void get(int&) = 0;"
ensures that subclasses have to implement the declared method. So the
base class knows a method implementation exists in all derived
classes.
He is trying to call a base class function that calls a derived classes
function, which is normally not done.
I object to that too. It's the concept of the Template Method Pattern
(1) combined with standard inheritance. It should work and in other
object oriented languages it does. So, why not in C++?
(1) Gamma, E. et alii (2004): Design Patterns Elements of Reusable
Object-Oriented Software, 31st Printing, Boston u.a.
The question isn't what should work, but what does work. My statements are
applying to how C++ works, not how other languages work or how you think C++
should work. There is enough to dicuss in C++ currently without discussing
what shoulda, woulda, coulda been in it. comp.std.c++ is the forum to
discuss those issues.