Re: subclassing question

Tech-Archive recommends: Fix windows errors by optimizing your registry



PaulH wrote:
ClassA typically requires you to open a handle to a resource and then
use that resource handle as the first argument to SomeFunction(). The
other arguments to SomeFunction() are parameters on how to use that
resource.

ClassB derives not only from ClassA but also from a ClassC (which I
did not show in my earlier example). ClassC is a wrapper for that
resource.

So, ClassB::SomeFunction() looks a bit like this:

ClassB::SomeFunction( int A, int B )
{
HANDLE C = OpenResource(); // This function is from "ClassC"
return SomeFunction( C, A, B );
}

So, the benefit of ClassB is that my program no longer has to manage
that resource separately. It's handled by virtue of using ClassB and
the result of using "SomeFunction()" is the same.

PaulH:

Yes, but there is no need to use the same name. You could call it ClassB::SomeOtherFunction(int A, int B). Then you would not hide ClassA::SomeFunction().

--
David Wilkinson
Visual C++ MVP
.



Relevant Pages

  • Re: subclassing question
    ... them ClassB and ClassA, respectively. ...     void SomeFunction(int A, int B, bool C) ... ClassA typically requires you to open a handle to a resource and then ...
    (microsoft.public.vc.language)
  • Re: subclassing question
    ... use that resource handle as the first argument to SomeFunction(). ... ClassB::SomeOtherFunction(int A, int B). ... MessageBox(LPCTSTR, LPCTSTR, UINT) throw" have the same name, but ...
    (microsoft.public.vc.language)
  • Re: subclassing question
    ... them ClassB and ClassA, respectively. ...    void SomeFunction(int A, int B, bool C) ...
    (microsoft.public.vc.language)