[RESOLVED] Deep inheritance and using directive
Hi,
is the following piece of code correct or am I doing something stupid?
Code:
struct A {};
struct B {};
struct C {};
struct Interface
{
virtual ~Interface()
{
}
virtual void func( const A& Obj ) = 0;
virtual void func( const B& Obj ) = 0;
virtual void func( const C& Obj ) = 0;
};
struct Default : Interface
{
virtual ~Default()
{
}
void func( const A& Obj ) {}
void func( const B& Obj ) {}
void func( const C& Obj ) {}
};
struct Special : Default
{
// bring all func methods of Default into scope
using Default::func;
// specialize on A
void func( const A& Obj )
{
}
};
I´ve got two compiler warnings:
(1) Special::func( const A& ) hides virtual function Default::func( const B& Obj )
(2) Special::func( const A& ) hides virtual function Default::func( const C& Obj )
Is my compiler correct? From my understanding I´m telling it I want all func methods from the bases class to be available in Special.
Re: Deep inheritance and using directive
The compiler warnings are wrong, and you can verify that by attempting to invoke the inherited func member functions that take a B and a C object by const reference respectively.
Re: Deep inheritance and using directive
VS 2008 & Comeau say :thumb:
Even PC-Lint is happy!
Re: Deep inheritance and using directive
Adding DevC's mingW to make it more real
Re: Deep inheritance and using directive
That´s what I already suspected. I ran it in Dinkumware´s online EXAM using different compilers and none showed any warnings.
Thanks to all of you for confirming this.
Re: Deep inheritance and using directive
That can be changed anytime due to bugs/outofdate versionxxxx