home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!fulcrum!rct
- From: rct@fulcrum.co.uk (Richard Taylor)
- Newsgroups: comp.lang.c++
- Subject: Re: Quest: Multiple Virtual functions with same name
- Message-ID: <BxAwAK.I1B@fulcrum.co.uk>
- Date: 6 Nov 92 15:27:55 GMT
- References: <1992Oct30.182516.20463@hplabsz.hpl.hp.com>
- Sender: Richard Taylor
- Organization: Fulcrum Communications
- Lines: 52
-
- In article <1992Oct30.182516.20463@hplabsz.hpl.hp.com> kalra@PROBLEM_WITH_INEWS_GATEWAY_FILE (Deven Kalra) writes:
- >
- >I have a question about having multiple virtual functions with same names.
- >
- >I have a base class as
- >
- >class BaseClass{
- >
- >
- > virtual render (Sphere &s);
- > virtual render (Rect &r);
- >}
- >
- >and a derived class
- >
- >class DerivedClass:public BaseClass{
- > virtual render (Sphere &s);
- >}
- >
- >I get compiler warnings as:
- >
- > render function hides base function
- >
- >Is it documented behavior? Why does not
- > render(Sphere &s) in DerivedClass
- >
- >replace
- > render(Sphere &s) in BaseClass
- >
- >but
- > render(Rect &r) be taken from the BaseClass.
- >
- >
- >Why should the above create a warning. Is there an alternative way
- >to achieve the above functionality of replacing only some of the functions
- >of a BaseClass that are named the same.
- >
-
- Isn't the problem that you have made *both* render (Sphere &s) functions
- virtual? That means the base virtual function will *never* be used. Maybe
- you meant:
-
- class DerivedClass:public BaseClass{
- /*virtual*/ render (Sphere &s);
-
-
- Regards,
- ============================================================================
- Richard Taylor DoD #981 (rct@fulcrum.co.uk) Heard on Radio 4:-
- "One of the first signs of the male menopause is buying a Harley Davidson."
- ============================================================================
- Fulcrum Communications Ltd., Fordrough Lane, Birmingham, B9 5LD, ENGLAND.
-