Base class

  • Thread starter Thread starter ezzatm
  • Start date Start date
E

ezzatm

I've a very simple question:-

if I run any method in the Mybase class, what exactly it will run
against?
e.g.
Let's say i have in my project a form (form1)
when i add such lines of code:
mybase.hide
mybase.height = 100
it runs against form1 (form1 is hided, form1 height changes)
but isn't mybase a base class which is shadowed or overriden by a
derived class?
Isn't this like referrring to a form.hide, or textbox.clear
which form and which text box??
 
if I run any method in the Mybase class, what exactly it will run
against?
e.g.
Let's say i have in my project a form (form1)
when i add such lines of code:
mybase.hide
mybase.height = 100
it runs against form1 (form1 is hided, form1 height changes)
but isn't mybase a base class which is shadowed or overriden by a
derived class?

No it actually runs against the base form. Form1 is decended from
System.Windows.Forms.Form or whatever the path is, so the code above
to hide and alter the dimensions is actually running against that.

Nothing is shadowed or overriden unless you explicitly do so. For
instance if you declare another property in Form1

Public Shadows Property Height etc.

Then your code above will call the property in form1 and you will have
to explicity call the height property in the base form

mybase.height = x

if you want to alter this property.

Dont ask ME to explain shadowing though.
I clench my buttocks every time i think about it.

It is straight forward for most but it ties my brain in knots for some
reason when you start getting into multi level inheritence, etc....
uugh I hate it. Although i understand it, i cant explain it, which is
kinda contridictory i know ....
Isn't this like referrring to a form.hide, or textbox.clear
which form and which text box??

Yeah thats what im talking about. It depends entirely on the
inheritence tree, what in the base class(es) has been shadowed and
overriden etc.

Theres a section in the docs, I think its the vb language guide
section 4.3.3 that talk's about it, quite nice with ex code. I had to
read that section about 5 times before i got it - dunno why?

hth
Richard
 
Back
Top