Re: subclassing question
- From: David Wilkinson <no-reply@xxxxxxxxxxxx>
- Date: Sun, 02 Nov 2008 06:45:11 -0500
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
.
- Follow-Ups:
- Re: subclassing question
- From: PaulH
- Re: subclassing question
- References:
- subclassing question
- From: PaulH
- Re: subclassing question
- From: David Wilkinson
- Re: subclassing question
- From: PaulH
- subclassing question
- Prev by Date: Re: Passing structs....
- Next by Date: Re: subclassing question
- Previous by thread: Re: subclassing question
- Next by thread: Re: subclassing question
- Index(es):
Relevant Pages
|