[Coin-discuss] Compiling Osi with gcc 2.95.3
Michael Hennebry
hennebry at web.cs.ndsu.nodak.edu
Fri Feb 18 16:37:51 EST 2005
On Fri, 18 Feb 2005, Lou Hafer wrote:
> Ted, John,
>
> I added the using declarations to suppress warnings from the Forte
> C++ compiler which complained that the more local declarations were hiding
> less local declarations. In effect, using brings the other declaration into
> scope for consideration in overload resolution. (Vague, I know. Will try to
> generate an example, but need to go and lecture just now.) Can't recall that
> I ever found a case where the code behaved incorrectly. It was strictly a
> matter of reducing compile time warnings.
A name in a derived class is supposed
to hide the same name in its base class.
class Base {
public:
virtual bool fred(const Base &rhs) const;
} ;
class Derived : public Base {
public:
// using Base::fred;
virtual bool fred(const Derived &rhs) const; // hides Base::fred
} ;
Derived dl, dr;
Base bl, br;
...
bl.fred(br); // refers to Base::fred
dl.fred(dr); // refers to Derived::fred
bl.fred(dr); // should not compile without using
// with using, refers to Base::fred
dl.fred(br); // I'm not sure if this should compile
// might be compiled as static_cast<Base &>(dl).fred(br)
// or as Base(dl)->fred(br)
// it might matter whether fred is an operator
In none of the above cases does the virtualness of fred matter.
--
Mike hennebry at web.cs.ndsu.NoDak.edu
"Our gods are dead. Ancient Klingon warriors slew them
... they were more trouble than they were worth." -- Worf
More information about the Coin-discuss
mailing list