Inheritance

  • Thread starter Thread starter Albert Krüger
  • Start date Start date
A

Albert Krüger

Hello

I have following problem:

'not a abstract class!
Public Class CBaseClass
Public Overridable AnyFunction() as Boolean
...
End Class

Public Class CSubClass
Inherits CBaseClass
Public Overloads AnyFunction() as Boolean
...
End Class

In another class I have a method:

Public Sub Anywhere(ByRef pobjAny As CBaseClass )
Begin
pobjAny.AnyFunction() 'here is my problem
End Sub

Now I have:

Dim CSubClass objSub
objSub = new CSubClass
Anywhere(objSub)

At method 'Anywhere' pobjAny.AnyFunction calls always the method of the base
class. But in some cases I need the call of AnyFunction of the base class,
sometimes of the sub class.

Where is my mistake?

Thanks
Albert Krüger
 
I have found my mistake.
I was a little bit confused because my function AnyFunction is overloaded
and (!) overwriteable.

Albert Krüger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top