Thanks. I don''t know what I was thinking. I think I need more coffee.
Stephen Manchester
Senior Technical Lead
Virtual Media Vision, Inc.
stephen@virtualmediavision.com
(310) 930-7349
Virtual Functions
quote:Original post by smanches
I think I need more coffee.
A good decision, in any situation.
EDIT: seriously, tho, I know what you were thinking. C++ has so little syntactic sugar in the language that it's downright bizarre for the virtual keyword in a derived class not to have any effect whatsoever. I assume the option of the useless "virtual" was put in the language to assuage the ego of some committee member who wanted C++ to look more like his pet OO language.
Don't listen to me. I've had too much coffee.
[edited by - sneftel on July 25, 2002 6:39:40 PM]
quote:Original post by Sneftel
it''s downright bizarre for the virtual keyword in a derived class not to have any effect whatsoever.
It''s also useful in certain circumstances. Consider:
#include <iostream>struct VirtualDtor{ virtual ~VirtualDtor() {}};struct StaticDtor{};template<class DestructionPolicy>struct Thing : public DestructionPolicy{ void f() { std::cout << "f()" << std::endl; }};class AggregatedThing{private: Thing<StaticDtor> st;};class DerivedThing : public Thing<VirtualDtor>{};int main(){ AggregatedThing at; DerivedThing dt;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement