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

Threaded View

  1. #2
    Join Date
    May 2009
    Posts
    2,413

    Re: Common base class + abstract interface class

    Quote Originally Posted by Jordgubbe View Post
    I know that all objects that inherit MyInterface also inherit MyBaseclass, but the compiler doesn't know that. MyContainerclass wants to call methods in MyBaseclass, but it collects pointers to MyInterface classes. I can't make MyInterface inherit MyBaseclass,
    You don't want to let MyInterface inherit MyBaseclass but maybe you could let MyInterface define a method which returns a pointer to MyBaseclass? Essentially that method just returns this.

    With such a method you can use any MyInterface object as a MyBaseclass object too (as long as it is a MyBaseclass object of course).
    Last edited by nuzzle; May 28th, 2013 at 03:25 PM.

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