Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-05-21 20:03:55


Rob Stewart <stewart_at_[hidden]> writes:

> From: "Reece Dunn" <msclrhd_at_[hidden]>
>>
>> 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... or just be disciplined about bringing the base names into
derived classes everywhere with "using".

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk