CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Nov 2006
    Location
    Essen, Germany
    Posts
    1,344

    [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.
    Last edited by GNiewerth; February 11th, 2009 at 12:23 PM. Reason: Typos fixed
    - Guido

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured