
From: "Aleksey Gurtovoy" <agurtovoy@meta-comm.com>
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 };
Sure, but you've both jumped off on a tangent unrelated to the purpose of the original query. See my reply to Dave's message. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;