Newsgroups: comp.lang.c++
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!bywater!arnor!watson!blinn.watson.ibm.com!mittle
From: mittle@blinn.watson.ibm.com (Josh Mittleman)
Subject: Re: virtual operators
Sender: @watson.ibm.com
Message-ID: <1991Jun03.205859.20814@watson.ibm.com>
Date: Mon, 03 Jun 91 20:58:59 GMT
References:  <1991Jun1.175904.20181@ux1.cso.uiuc.edu>
Organization: IBM T. J. Watson Research

In article <1991Jun1.175904.20181@ux1.cso.uiuc.edu>,
bernied@yoyodyne.ncsa.uiuc.edu (Bernhard Damberger) writes:
> 
> 	I 'am having some problems with virtual operators...maybe some 
> one out there can help me.  I have a class (called Base) that acts as a base 
> class for all other classes.  Base has all the relational operators defined 
> (<, >, <=, etc.) as virtual. There is a subclass of Base (called
TestInt) that 
> overides the relational operators with its own (CFront even says TestInt's 
> operators are hiding Base's operators).  It looks something like this (some 
> code deleted):

Without reading any further, it is pretty clear what your problem is.
Virtual functions must have identical signatures.
Subclass::operator<(Subclass&) is not the same signature as
BaseClass::operator<(BaseClass&), and the virtual function mechanism will
not see a match.  To get the virtual behavior, the Subclass function must
have the signature Subclass::operator<(BaseClass&).

When your compiler tells you that TestInt's operators are hiding Base's
operators, that is a warning of a probable error.  It means that TestInt's
operators are not being treated as virtual functions.

===========================================================================
Josh Mittleman (mittle@watson.ibm.com or joshua@paul.rutgers.edu)
J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY  10598
