
David Abrahams writes:
From: "Reece Dunn" <msclrhd@hotmail.com>
Q: Since the above is valid C++, is the following?: virtual void myfn( char ) = 0; virtual void myfn( int, bool ) = 0;
Absolutely. You can overload virtual functions just like non-virtual functions.
But unless they're all going to be overridden in one single class you're better off using the "template method pattern" and dispatching to differently-named functions to avoid problems with name hiding...
Yep, something like this: class base { public: void something() { do_something(); } void something(int n) { do_something(n); } private: virtual void do_something() = 0; virtual void do_something(int n) = 0; }; class derived : public base { // both 'something' are still visible private: virtual void do_something(int n); // OK }; -- Aleksey Gurtovoy MetaCommunications Engineering