473,799 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritance Question

I am playing with Inheritance and want to make sure I understand it.

I have the following Classes:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

I assume that inheritance depends on the order of definition.

Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it would
have been defined second. So if I create TempClass1, it would work
something like, SessionKey would first be "Default" but then ServiceTicket
would re-define it, since it inherited it (and is higher up the chain) and
change it to "Default from ServiceTicket".

In this case, if I had:

Dim objTempClass1 As new TempClass1
Dim objServiceTicke t As new ServiceTicket
Dim objAuthHeader As new AuthHeader

objTempClass1.S essionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.S essionKey = "Default from ServiceTicket"
objAuthHeader.S essionKey = "Default"

But if I took out the Sessionkey from the ServiceKey class that it would be:

objTempClass1.S essionKey = "Default" ' Inherited from
AuthHeader
objServiceKey.S essionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.S essionKey = "Default"

Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Is there any good reason to defining SessionKey again ServiceTicket?

I assume since it always would inherit from AuthHeader, it would always get
SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:

SessionKey = "Default"

without needing to redefine it.

Is this correct?

Thanks,

Tom
Apr 3 '06 #1
6 1675
First, you shouldn't have public fields...but I'll assume you were only
using them for illustrative purposes

Your code will generate warnings, and it's a good idea to fix those
warnings, especially as they pertain directly to your questions.

It's bad practice to reuse the names like you are doing. If you want to do
it, you should declare the SessionKey field in ServiceTicket as "shadows"
ala:

public shadows SessionKey as string

this means that the SessionKey in ServiceTicket is used instead of the onne
in AuthHeader for both ServiceTicket and TempClass1 - it's the same
behaviour as if you don't specify shadows, but it's more explicit and
removes the warning.

Also, if you use properties, you can mark the SessionKey property in the
base AuthHEader class as "overridabl e" which means child-classes can
implement the property as "overrides" .

Now there is a difference between a property that shadows and one that
overrides. Take for example:

Public Class AuthHeader
Public Readonly overridable property SessionKey As String
get
return "DEFAULT"
end get
end property
End Class

Public Class ServiceTicket
Inherits AuthHeader

Public Readonly shadows property SessionKey As String
get
return "DEFAULT SESSION"
end get
end property
End Class

Public Class TempClass1
Inherits ServiceTicket

End Class
If we do:

dim temp as new TempClass1()
Console.WriteLi ne(temp.Session Key)
Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)

we'll get

DEFAULT SESSION
DEFAULT

as you can see, by using shadows and casting to the base type, the base type
is outputted.

If we run the same test but change the "shadows" to "overrides" we'll get
DEFAULT SESSION both times.

Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:uO******** ******@TK2MSFTN GP11.phx.gbl...
I am playing with Inheritance and want to make sure I understand it.

I have the following Classes:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

I assume that inheritance depends on the order of definition.

Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it
would have been defined second. So if I create TempClass1, it would work
something like, SessionKey would first be "Default" but then ServiceTicket
would re-define it, since it inherited it (and is higher up the chain) and
change it to "Default from ServiceTicket".

In this case, if I had:

Dim objTempClass1 As new TempClass1
Dim objServiceTicke t As new ServiceTicket
Dim objAuthHeader As new AuthHeader

objTempClass1.S essionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.S essionKey = "Default from ServiceTicket"
objAuthHeader.S essionKey = "Default"

But if I took out the Sessionkey from the ServiceKey class that it would
be:

objTempClass1.S essionKey = "Default" ' Inherited
from AuthHeader
objServiceKey.S essionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.S essionKey = "Default"

Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Is there any good reason to defining SessionKey again ServiceTicket?

I assume since it always would inherit from AuthHeader, it would always
get SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:

SessionKey = "Default"

without needing to redefine it.

Is this correct?

Thanks,

Tom

Apr 3 '06 #2
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:e4******** ******@TK2MSFTN GP15.phx.gbl...
First, you shouldn't have public fields...but I'll assume you were only
using them for illustrative purposes
Yes.

I would normally use Properties or Protected.

Your code will generate warnings, and it's a good idea to fix those
warnings, especially as they pertain directly to your questions.

It's bad practice to reuse the names like you are doing. If you want to
do it, you should declare the SessionKey field in ServiceTicket as
"shadows"
That was one of my questions.

In this code, the SessionKey in the ServiceTicket is really irrelevant, is
it not?

I don't know why the example code was using it this way, since we would only
get one SessionKey. The only way I can think that this would be relevent
would be if the first SessionKey were set to some default value and you
wanted to override the value, but you could do that just as easily, as I
mentioned by just setting it.

I just wanted to see if I was missiong something.
ala:

public shadows SessionKey as string
Wouldn't this be the same as my question above? Why would I use that,
wouldn't there just be one variable?

this means that the SessionKey in ServiceTicket is used instead of the
onne in AuthHeader for both ServiceTicket and TempClass1 - it's the same
behaviour as if you don't specify shadows, but it's more explicit and
removes the warning.
Actually, I didn't get any warnings. I am using vbc to compile it. Maybe
that is different from using it in VB 2003.

Also, if you use properties, you can mark the SessionKey property in the
base AuthHEader class as "overridabl e" which means child-classes can
implement the property as "overrides" .

Now there is a difference between a property that shadows and one that
overrides. Take for example:

Public Class AuthHeader
Public Readonly overridable property SessionKey As String
get
return "DEFAULT"
end get
end property
End Class

Public Class ServiceTicket
Inherits AuthHeader

Public Readonly shadows property SessionKey As String
get
return "DEFAULT SESSION"
end get
end property
End Class

Public Class TempClass1
Inherits ServiceTicket

End Class
If we do:

dim temp as new TempClass1()
Console.WriteLi ne(temp.Session Key)
Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)

we'll get

DEFAULT SESSION
DEFAULT

as you can see, by using shadows and casting to the base type, the base
type is outputted.

If we run the same test but change the "shadows" to "overrides" we'll get
DEFAULT SESSION both times.
So in my example (even though not properties), I assume I was doing an
"override" (which I also assume is the default) and you only have one
variable. With "shadows" I assume you have 2 variables. In my example,
could I have used Shadows in my Public statement and end up with 2 variables
that way?

I know it is not the best way, but just trying to get the theory down.

Thanks,

Tom
Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:uO******** ******@TK2MSFTN GP11.phx.gbl...
I am playing with Inheritance and want to make sure I understand it.

I have the following Classes:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

I assume that inheritance depends on the order of definition.

Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it
would have been defined second. So if I create TempClass1, it would work
something like, SessionKey would first be "Default" but then
ServiceTicket would re-define it, since it inherited it (and is higher up
the chain) and change it to "Default from ServiceTicket".

In this case, if I had:

Dim objTempClass1 As new TempClass1
Dim objServiceTicke t As new ServiceTicket
Dim objAuthHeader As new AuthHeader

objTempClass1.S essionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.S essionKey = "Default from ServiceTicket"
objAuthHeader.S essionKey = "Default"

But if I took out the Sessionkey from the ServiceKey class that it would
be:

objTempClass1.S essionKey = "Default" ' Inherited
from AuthHeader
objServiceKey.S essionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.S essionKey = "Default"

Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Is there any good reason to defining SessionKey again ServiceTicket?

I assume since it always would inherit from AuthHeader, it would always
get SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:

SessionKey = "Default"

without needing to redefine it.

Is this correct?

Thanks,

Tom


Apr 3 '06 #3
WEll, sometimes you want to overwrite functionality in a base class. If you
control the base case, you'd mark the method as "overridabl e" and let sub
classes "overrides" it. A good example of this is the ToString() method
which is marked as "overridabl e" in the System.Object class, and which many
child classes "overrides" .

The only time I've used shadows is when I don't control the base class (ie,
it's a library and I don't have the source) and I want to override
functionality. If that member isn't "overridabl e" then "shadows" is the only
way I can do it.

You seem to be implying that overriding/shadowing is irrelevant.I can't
agree with that. It's true that you probably won't use them often (shadows
less that overrides), but they are still useful tools to have. I find that I
write abstract members more, but that might just be me.

Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:e4******** ******@TK2MSFTN GP15.phx.gbl...
First, you shouldn't have public fields...but I'll assume you were only
using them for illustrative purposes


Yes.

I would normally use Properties or Protected.

Your code will generate warnings, and it's a good idea to fix those
warnings, especially as they pertain directly to your questions.

It's bad practice to reuse the names like you are doing. If you want to
do it, you should declare the SessionKey field in ServiceTicket as
"shadows"


That was one of my questions.

In this code, the SessionKey in the ServiceTicket is really irrelevant, is
it not?

I don't know why the example code was using it this way, since we would
only get one SessionKey. The only way I can think that this would be
relevent would be if the first SessionKey were set to some default value
and you wanted to override the value, but you could do that just as
easily, as I mentioned by just setting it.

I just wanted to see if I was missiong something.
ala:

public shadows SessionKey as string


Wouldn't this be the same as my question above? Why would I use that,
wouldn't there just be one variable?

this means that the SessionKey in ServiceTicket is used instead of the
onne in AuthHeader for both ServiceTicket and TempClass1 - it's the same
behaviour as if you don't specify shadows, but it's more explicit and
removes the warning.


Actually, I didn't get any warnings. I am using vbc to compile it. Maybe
that is different from using it in VB 2003.

Also, if you use properties, you can mark the SessionKey property in the
base AuthHEader class as "overridabl e" which means child-classes can
implement the property as "overrides" .

Now there is a difference between a property that shadows and one that
overrides. Take for example:

Public Class AuthHeader
Public Readonly overridable property SessionKey As String
get
return "DEFAULT"
end get
end property
End Class

Public Class ServiceTicket
Inherits AuthHeader

Public Readonly shadows property SessionKey As String
get
return "DEFAULT SESSION"
end get
end property
End Class

Public Class TempClass1
Inherits ServiceTicket

End Class
If we do:

dim temp as new TempClass1()
Console.WriteLi ne(temp.Session Key)
Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)

we'll get

DEFAULT SESSION
DEFAULT

as you can see, by using shadows and casting to the base type, the base
type is outputted.

If we run the same test but change the "shadows" to "overrides" we'll get
DEFAULT SESSION both times.

So in my example (even though not properties), I assume I was doing an
"override" (which I also assume is the default) and you only have one
variable. With "shadows" I assume you have 2 variables. In my example,
could I have used Shadows in my Public statement and end up with 2
variables that way?

I know it is not the best way, but just trying to get the theory down.

Thanks,

Tom
Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:uO******** ******@TK2MSFTN GP11.phx.gbl...
I am playing with Inheritance and want to make sure I understand it.

I have the following Classes:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

I assume that inheritance depends on the order of definition.

Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it
would have been defined second. So if I create TempClass1, it would
work something like, SessionKey would first be "Default" but then
ServiceTicket would re-define it, since it inherited it (and is higher
up the chain) and change it to "Default from ServiceTicket".

In this case, if I had:

Dim objTempClass1 As new TempClass1
Dim objServiceTicke t As new ServiceTicket
Dim objAuthHeader As new AuthHeader

objTempClass1.S essionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.S essionKey = "Default from ServiceTicket"
objAuthHeader.S essionKey = "Default"

But if I took out the Sessionkey from the ServiceKey class that it would
be:

objTempClass1.S essionKey = "Default" ' Inherited
from AuthHeader
objServiceKey.S essionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.S essionKey = "Default"

Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Is there any good reason to defining SessionKey again ServiceTicket?

I assume since it always would inherit from AuthHeader, it would always
get SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:

SessionKey = "Default"

without needing to redefine it.

Is this correct?

Thanks,

Tom



Apr 4 '06 #4
I think you were misunderstandin g what I was saying here.

I was not disagreeing with you on overrides were irrelevant. That wasn't
what I was asking. I know they are. I wasn't sure why I would use
shadowing until you explained how it was used.

In my example, I was trying to figure out why you would override SessionKey
in the case where there was no default value.

*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Since SessionKey is not set to anything in AuthHeader and since SessionKey
will override it, why have it at all, as you will have access to the
variable since it is inherited? What do you gain (this case only)?

If it was:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "some value"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Then I can see why you would do it. I just wanted to see if I was missing
anything.

On the question of using Shadowing a Base Class (library) where you don't
have the source, wouldn't that be kind of dangerous to Shadow a variable. I
assume you would only do that if you have documentation telling you how the
field is used. If it were not overridable, wouldn't that be because it
would cause some problem if you did?

One of the reasons I started doing this is because of the other post I did
about "Creating Generic Classes from 2 Classes", earlier today.

I have 2 classes that are exactly identical, except for a URL value. I
would be using it to allow me to use all the methods and properties from one
set of code. I tried just changing the URL, but that works for some of the
routines, but not all of them. I thought I could just set up a pointer that
pointer that pointed to one class of the other (setting it as an object) but
I had problem access the methods. So I thought maybe I could solve it
somehow using classes and overriding the methods or maybe as an interface
(haven't really looked at that yet).

So I am just playing with this to see if it would work before I start
redoing all the code.

Thanks,

Tom

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:ec******** ******@TK2MSFTN GP11.phx.gbl...
WEll, sometimes you want to overwrite functionality in a base class. If you control the base case, you'd mark the method as "overridabl e" and let sub
classes "overrides" it. A good example of this is the ToString() method
which is marked as "overridabl e" in the System.Object class, and which many child classes "overrides" .

The only time I've used shadows is when I don't control the base class (ie, it's a library and I don't have the source) and I want to override
functionality. If that member isn't "overridabl e" then "shadows" is the only way I can do it.

You seem to be implying that overriding/shadowing is irrelevant.I can't
agree with that. It's true that you probably won't use them often (shadows
less that overrides), but they are still useful tools to have. I find that I write abstract members more, but that might just be me.

Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:e4******** ******@TK2MSFTN GP15.phx.gbl...
First, you shouldn't have public fields...but I'll assume you were only
using them for illustrative purposes


Yes.

I would normally use Properties or Protected.

Your code will generate warnings, and it's a good idea to fix those
warnings, especially as they pertain directly to your questions.

It's bad practice to reuse the names like you are doing. If you want to do it, you should declare the SessionKey field in ServiceTicket as
"shadows"


That was one of my questions.

In this code, the SessionKey in the ServiceTicket is really irrelevant, is it not?

I don't know why the example code was using it this way, since we would
only get one SessionKey. The only way I can think that this would be
relevent would be if the first SessionKey were set to some default value
and you wanted to override the value, but you could do that just as
easily, as I mentioned by just setting it.

I just wanted to see if I was missiong something.
ala:

public shadows SessionKey as string


Wouldn't this be the same as my question above? Why would I use that,
wouldn't there just be one variable?

this means that the SessionKey in ServiceTicket is used instead of the
onne in AuthHeader for both ServiceTicket and TempClass1 - it's the same behaviour as if you don't specify shadows, but it's more explicit and
removes the warning.


Actually, I didn't get any warnings. I am using vbc to compile it. Maybe that is different from using it in VB 2003.

Also, if you use properties, you can mark the SessionKey property in the base AuthHEader class as "overridabl e" which means child-classes can
implement the property as "overrides" .

Now there is a difference between a property that shadows and one that
overrides. Take for example:

Public Class AuthHeader
Public Readonly overridable property SessionKey As String
get
return "DEFAULT"
end get
end property
End Class

Public Class ServiceTicket
Inherits AuthHeader

Public Readonly shadows property SessionKey As String
get
return "DEFAULT SESSION"
end get
end property
End Class

Public Class TempClass1
Inherits ServiceTicket

End Class
If we do:

dim temp as new TempClass1()
Console.WriteLi ne(temp.Session Key)
Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)

we'll get

DEFAULT SESSION
DEFAULT

as you can see, by using shadows and casting to the base type, the base
type is outputted.

If we run the same test but change the "shadows" to "overrides" we'll get DEFAULT SESSION both times.

So in my example (even though not properties), I assume I was doing an
"override" (which I also assume is the default) and you only have one
variable. With "shadows" I assume you have 2 variables. In my example,
could I have used Shadows in my Public statement and end up with 2
variables that way?

I know it is not the best way, but just trying to get the theory down.

Thanks,

Tom
Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:uO******** ******@TK2MSFTN GP11.phx.gbl...
I am playing with Inheritance and want to make sure I understand it.

I have the following Classes:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

I assume that inheritance depends on the order of definition.

Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it
would have been defined second. So if I create TempClass1, it would
work something like, SessionKey would first be "Default" but then
ServiceTicket would re-define it, since it inherited it (and is higher
up the chain) and change it to "Default from ServiceTicket".

In this case, if I had:

Dim objTempClass1 As new TempClass1
Dim objServiceTicke t As new ServiceTicket
Dim objAuthHeader As new AuthHeader

objTempClass1.S essionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.S essionKey = "Default from ServiceTicket"
objAuthHeader.S essionKey = "Default"

But if I took out the Sessionkey from the ServiceKey class that it would be:

objTempClass1.S essionKey = "Default" ' Inherited from AuthHeader
objServiceKey.S essionKey = "Default" ' Inherited from AuthHeader
objAuthHeader.S essionKey = "Default"

Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Is there any good reason to defining SessionKey again ServiceTicket?

I assume since it always would inherit from AuthHeader, it would always get SessionKey from the inheritance. If it wanted to set SessionKey in ServiceTicket, it could just set it by:

SessionKey = "Default"

without needing to redefine it.

Is this correct?

Thanks,

Tom



Apr 4 '06 #5
All variables have default values. But I agree there seems to be little
point of overriding something with the same value (null for now) up front.

Yes, shadowing can be risky, but sometimes necessary. It's particularly bad
when you get a code update which changes the mechanics of the base
implementation, which your code is now shadowing. Like overrides, you can
call the base implementation in shadows via mybase.SessionK ey I believe
(again, not applicable to fields).

If I understand your problem, the best solution seems to be to implement a
base class, mark the property as overriable, and have 2 child classes
overrides the property to set their specific url.

Karl

--
http://www.openmymind.net/

"tshad" <tf*@dslextreme .com> wrote in message
news:u%******** ********@TK2MSF TNGP09.phx.gbl. ..
I think you were misunderstandin g what I was saying here.

I was not disagreeing with you on overrides were irrelevant. That wasn't
what I was asking. I know they are. I wasn't sure why I would use
shadowing until you explained how it was used.

In my example, I was trying to figure out why you would override
SessionKey
in the case where there was no default value.

*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Since SessionKey is not set to anything in AuthHeader and since SessionKey
will override it, why have it at all, as you will have access to the
variable since it is inherited? What do you gain (this case only)?

If it was:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "some value"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Then I can see why you would do it. I just wanted to see if I was missing
anything.

On the question of using Shadowing a Base Class (library) where you don't
have the source, wouldn't that be kind of dangerous to Shadow a variable.
I
assume you would only do that if you have documentation telling you how
the
field is used. If it were not overridable, wouldn't that be because it
would cause some problem if you did?

One of the reasons I started doing this is because of the other post I did
about "Creating Generic Classes from 2 Classes", earlier today.

I have 2 classes that are exactly identical, except for a URL value. I
would be using it to allow me to use all the methods and properties from
one
set of code. I tried just changing the URL, but that works for some of
the
routines, but not all of them. I thought I could just set up a pointer
that
pointer that pointed to one class of the other (setting it as an object)
but
I had problem access the methods. So I thought maybe I could solve it
somehow using classes and overriding the methods or maybe as an interface
(haven't really looked at that yet).

So I am just playing with this to see if it would work before I start
redoing all the code.

Thanks,

Tom

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:ec******** ******@TK2MSFTN GP11.phx.gbl...
WEll, sometimes you want to overwrite functionality in a base class. If

you
control the base case, you'd mark the method as "overridabl e" and let sub
classes "overrides" it. A good example of this is the ToString() method
which is marked as "overridabl e" in the System.Object class, and which

many
child classes "overrides" .

The only time I've used shadows is when I don't control the base class

(ie,
it's a library and I don't have the source) and I want to override
functionality. If that member isn't "overridabl e" then "shadows" is the

only
way I can do it.

You seem to be implying that overriding/shadowing is irrelevant.I can't
agree with that. It's true that you probably won't use them often
(shadows
less that overrides), but they are still useful tools to have. I find
that

I
write abstract members more, but that might just be me.

Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> "Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO .
> ANDME
> net> wrote in message news:e4******** ******@TK2MSFTN GP15.phx.gbl...
>> First, you shouldn't have public fields...but I'll assume you were
>> only
>> using them for illustrative purposes
>
> Yes.
>
> I would normally use Properties or Protected.
>
>>
>> Your code will generate warnings, and it's a good idea to fix those
>> warnings, especially as they pertain directly to your questions.
>>
>> It's bad practice to reuse the names like you are doing. If you want to >> do it, you should declare the SessionKey field in ServiceTicket as
>> "shadows"
>
> That was one of my questions.
>
> In this code, the SessionKey in the ServiceTicket is really irrelevant, is > it not?
>
> I don't know why the example code was using it this way, since we would
> only get one SessionKey. The only way I can think that this would be
> relevent would be if the first SessionKey were set to some default
> value
> and you wanted to override the value, but you could do that just as
> easily, as I mentioned by just setting it.
>
> I just wanted to see if I was missiong something.
>
>> ala:
>>
>> public shadows SessionKey as string
>
> Wouldn't this be the same as my question above? Why would I use that,
> wouldn't there just be one variable?
>
>>
>> this means that the SessionKey in ServiceTicket is used instead of the
>> onne in AuthHeader for both ServiceTicket and TempClass1 - it's the same >> behaviour as if you don't specify shadows, but it's more explicit and
>> removes the warning.
>
> Actually, I didn't get any warnings. I am using vbc to compile it. Maybe > that is different from using it in VB 2003.
>
>>
>> Also, if you use properties, you can mark the SessionKey property in the >> base AuthHEader class as "overridabl e" which means child-classes can
>> implement the property as "overrides" .
>>
>> Now there is a difference between a property that shadows and one that
>> overrides. Take for example:
>>
>> Public Class AuthHeader
>> Public Readonly overridable property SessionKey As String
>> get
>> return "DEFAULT"
>> end get
>> end property
>> End Class
>>
>> Public Class ServiceTicket
>> Inherits AuthHeader
>>
>> Public Readonly shadows property SessionKey As String
>> get
>> return "DEFAULT SESSION"
>> end get
>> end property
>> End Class
>>
>> Public Class TempClass1
>> Inherits ServiceTicket
>>
>> End Class
>>
>>
>> If we do:
>>
>> dim temp as new TempClass1()
>> Console.WriteLi ne(temp.Session Key)
>> Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)
>>
>> we'll get
>>
>> DEFAULT SESSION
>> DEFAULT
>>
>> as you can see, by using shadows and casting to the base type, the
>> base
>> type is outputted.
>>
>> If we run the same test but change the "shadows" to "overrides" we'll get >> DEFAULT SESSION both times.
>>
> So in my example (even though not properties), I assume I was doing an
> "override" (which I also assume is the default) and you only have one
> variable. With "shadows" I assume you have 2 variables. In my
> example,
> could I have used Shadows in my Public statement and end up with 2
> variables that way?
>
> I know it is not the best way, but just trying to get the theory down.
>
> Thanks,
>
> Tom
>
>> Karl
>>
>>
>>
>> --
>> http://www.openmymind.net/
>>
>>
>>
>> "tshad" <ts**********@f tsolutions.com> wrote in message
>> news:uO******** ******@TK2MSFTN GP11.phx.gbl...
>>>I am playing with Inheritance and want to make sure I understand it.
>>>
>>> I have the following Classes:
>>> *************** *************** *************
>>> Public Class AuthHeader:Inhe rits SoapHeader
>>> Public AuthHeaderName As String
>>> Public SessionKey As String = "Default"
>>> End Class
>>>
>>> Public Class ServiceTicket:I nherits AuthHeader
>>> Public IsAuthenticated As Boolean
>>> Public SessionKey As String = "Default from ServiceTicket"
>>> Public Expiration As DateTime
>>> End Class
>>>
>>> Public Class TempClass1:Inhe rits ServiceTicket
>>> Public TomsClass1Name As String
>>> End Class
>>> *************** *************** ***********
>>>
>>> I assume that inheritance depends on the order of definition.
>>>
>>> Here SessionKey is being defined in 2 classes. For TempClass1 and
>>> ServiceTicket, Session would be "Default from ServiceTicket" since it
>>> would have been defined second. So if I create TempClass1, it would
>>> work something like, SessionKey would first be "Default" but then
>>> ServiceTicket would re-define it, since it inherited it (and is
>>> higher
>>> up the chain) and change it to "Default from ServiceTicket".
>>>
>>> In this case, if I had:
>>>
>>> Dim objTempClass1 As new TempClass1
>>> Dim objServiceTicke t As new ServiceTicket
>>> Dim objAuthHeader As new AuthHeader
>>>
>>> objTempClass1.S essionKey = "Default from ServiceTicket" '
>>> Inherited from ServiceKey
>>> objServiceKey.S essionKey = "Default from ServiceTicket"
>>> objAuthHeader.S essionKey = "Default"
>>>
>>> But if I took out the Sessionkey from the ServiceKey class that it would >>> be:
>>>
>>> objTempClass1.S essionKey = "Default" ' Inherited >>> from AuthHeader
>>> objServiceKey.S essionKey = "Default" ' Inherited >>> from AuthHeader
>>> objAuthHeader.S essionKey = "Default"
>>>
>>> Also, I originally got this from a sample program that didn't set
>>> the
>>> defaults, but had it defined as:
>>> *************** *************** *************
>>> Public Class AuthHeader:Inhe rits SoapHeader
>>> Public AuthHeaderName As String
>>> Public SessionKey As String
>>> End Class
>>>
>>> Public Class ServiceTicket:I nherits AuthHeader
>>> Public IsAuthenticated As Boolean
>>> Public SessionKey As String
>>> Public Expiration As DateTime
>>> End Class
>>>
>>> Public Class TempClass1:Inhe rits ServiceTicket
>>> Public TomsClass1Name As String
>>> End Class
>>> *************** *************** ***********
>>>
>>> Is there any good reason to defining SessionKey again ServiceTicket?
>>>
>>> I assume since it always would inherit from AuthHeader, it would always >>> get SessionKey from the inheritance. If it wanted to set SessionKey in >>> ServiceTicket, it could just set it by:
>>>
>>> SessionKey = "Default"
>>>
>>> without needing to redefine it.
>>>
>>> Is this correct?
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>>
>>
>>
>
>



Apr 4 '06 #6
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
All variables have default values. But I agree there seems to be little
point of overriding something with the same value (null for now) up front.

Yes, shadowing can be risky, but sometimes necessary. It's particularly
bad when you get a code update which changes the mechanics of the base
implementation, which your code is now shadowing. Like overrides, you can
call the base implementation in shadows via mybase.SessionK ey I believe
(again, not applicable to fields).

If I understand your problem, the best solution seems to be to implement a
base class, mark the property as overriable, and have 2 child classes
overrides the property to set their specific url.
Actually, I just want to set up multiple occurrences of a web service in my
code and just assign it to a generic object and use that object in the code.
Changing the URL doesn't work for all the web services. Someone said it
worked fine for him just changing the URL, and that is the case for some of
my web services, but not all. Instead of trying to make that work, I was
trying another way by adding a new web service for each server. But I can't
get that to work.

The problem is setting a base class and then setup these web services to
inherit the web services. I have no access to the source.

Thanks,

Tom
Karl

--
http://www.openmymind.net/

"tshad" <tf*@dslextreme .com> wrote in message
news:u%******** ********@TK2MSF TNGP09.phx.gbl. ..
I think you were misunderstandin g what I was saying here.

I was not disagreeing with you on overrides were irrelevant. That wasn't
what I was asking. I know they are. I wasn't sure why I would use
shadowing until you explained how it was used.

In my example, I was trying to figure out why you would override
SessionKey
in the case where there was no default value.

*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Since SessionKey is not set to anything in AuthHeader and since
SessionKey
will override it, why have it at all, as you will have access to the
variable since it is inherited? What do you gain (this case only)?

If it was:
*************** *************** *************
Public Class AuthHeader:Inhe rits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "some value"
End Class

Public Class ServiceTicket:I nherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class

Public Class TempClass1:Inhe rits ServiceTicket
Public TomsClass1Name As String
End Class
*************** *************** ***********

Then I can see why you would do it. I just wanted to see if I was
missing
anything.

On the question of using Shadowing a Base Class (library) where you don't
have the source, wouldn't that be kind of dangerous to Shadow a variable.
I
assume you would only do that if you have documentation telling you how
the
field is used. If it were not overridable, wouldn't that be because it
would cause some problem if you did?

One of the reasons I started doing this is because of the other post I
did
about "Creating Generic Classes from 2 Classes", earlier today.

I have 2 classes that are exactly identical, except for a URL value. I
would be using it to allow me to use all the methods and properties from
one
set of code. I tried just changing the URL, but that works for some of
the
routines, but not all of them. I thought I could just set up a pointer
that
pointer that pointed to one class of the other (setting it as an object)
but
I had problem access the methods. So I thought maybe I could solve it
somehow using classes and overriding the methods or maybe as an interface
(haven't really looked at that yet).

So I am just playing with this to see if it would work before I start
redoing all the code.

Thanks,

Tom

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:ec******** ******@TK2MSFTN GP11.phx.gbl...
WEll, sometimes you want to overwrite functionality in a base class. If

you
control the base case, you'd mark the method as "overridabl e" and let
sub
classes "overrides" it. A good example of this is the ToString() method
which is marked as "overridabl e" in the System.Object class, and which

many
child classes "overrides" .

The only time I've used shadows is when I don't control the base class

(ie,
it's a library and I don't have the source) and I want to override
functionality. If that member isn't "overridabl e" then "shadows" is the

only
way I can do it.

You seem to be implying that overriding/shadowing is irrelevant.I can't
agree with that. It's true that you probably won't use them often
(shadows
less that overrides), but they are still useful tools to have. I find
that

I
write abstract members more, but that might just be me.

Karl

--
http://www.openmymind.net/

"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> "Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO .
> ANDME
> net> wrote in message news:e4******** ******@TK2MSFTN GP15.phx.gbl...
>> First, you shouldn't have public fields...but I'll assume you were
>> only
>> using them for illustrative purposes
>
> Yes.
>
> I would normally use Properties or Protected.
>
>>
>> Your code will generate warnings, and it's a good idea to fix those
>> warnings, especially as they pertain directly to your questions.
>>
>> It's bad practice to reuse the names like you are doing. If you want

to
>> do it, you should declare the SessionKey field in ServiceTicket as
>> "shadows"
>
> That was one of my questions.
>
> In this code, the SessionKey in the ServiceTicket is really
> irrelevant,

is
> it not?
>
> I don't know why the example code was using it this way, since we
> would
> only get one SessionKey. The only way I can think that this would be
> relevent would be if the first SessionKey were set to some default
> value
> and you wanted to override the value, but you could do that just as
> easily, as I mentioned by just setting it.
>
> I just wanted to see if I was missiong something.
>
>> ala:
>>
>> public shadows SessionKey as string
>
> Wouldn't this be the same as my question above? Why would I use that,
> wouldn't there just be one variable?
>
>>
>> this means that the SessionKey in ServiceTicket is used instead of
>> the
>> onne in AuthHeader for both ServiceTicket and TempClass1 - it's the

same
>> behaviour as if you don't specify shadows, but it's more explicit and
>> removes the warning.
>
> Actually, I didn't get any warnings. I am using vbc to compile it.

Maybe
> that is different from using it in VB 2003.
>
>>
>> Also, if you use properties, you can mark the SessionKey property in

the
>> base AuthHEader class as "overridabl e" which means child-classes can
>> implement the property as "overrides" .
>>
>> Now there is a difference between a property that shadows and one
>> that
>> overrides. Take for example:
>>
>> Public Class AuthHeader
>> Public Readonly overridable property SessionKey As String
>> get
>> return "DEFAULT"
>> end get
>> end property
>> End Class
>>
>> Public Class ServiceTicket
>> Inherits AuthHeader
>>
>> Public Readonly shadows property SessionKey As String
>> get
>> return "DEFAULT SESSION"
>> end get
>> end property
>> End Class
>>
>> Public Class TempClass1
>> Inherits ServiceTicket
>>
>> End Class
>>
>>
>> If we do:
>>
>> dim temp as new TempClass1()
>> Console.WriteLi ne(temp.Session Key)
>> Console.WRiteLi ne(ctype(temp, AuthHeader).Ses sionKey)
>>
>> we'll get
>>
>> DEFAULT SESSION
>> DEFAULT
>>
>> as you can see, by using shadows and casting to the base type, the
>> base
>> type is outputted.
>>
>> If we run the same test but change the "shadows" to "overrides" we'll

get
>> DEFAULT SESSION both times.
>>
> So in my example (even though not properties), I assume I was doing an
> "override" (which I also assume is the default) and you only have one
> variable. With "shadows" I assume you have 2 variables. In my
> example,
> could I have used Shadows in my Public statement and end up with 2
> variables that way?
>
> I know it is not the best way, but just trying to get the theory down.
>
> Thanks,
>
> Tom
>
>> Karl
>>
>>
>>
>> --
>> http://www.openmymind.net/
>>
>>
>>
>> "tshad" <ts**********@f tsolutions.com> wrote in message
>> news:uO******** ******@TK2MSFTN GP11.phx.gbl...
>>>I am playing with Inheritance and want to make sure I understand it.
>>>
>>> I have the following Classes:
>>> *************** *************** *************
>>> Public Class AuthHeader:Inhe rits SoapHeader
>>> Public AuthHeaderName As String
>>> Public SessionKey As String = "Default"
>>> End Class
>>>
>>> Public Class ServiceTicket:I nherits AuthHeader
>>> Public IsAuthenticated As Boolean
>>> Public SessionKey As String = "Default from ServiceTicket"
>>> Public Expiration As DateTime
>>> End Class
>>>
>>> Public Class TempClass1:Inhe rits ServiceTicket
>>> Public TomsClass1Name As String
>>> End Class
>>> *************** *************** ***********
>>>
>>> I assume that inheritance depends on the order of definition.
>>>
>>> Here SessionKey is being defined in 2 classes. For TempClass1 and
>>> ServiceTicket, Session would be "Default from ServiceTicket" since
>>> it
>>> would have been defined second. So if I create TempClass1, it would
>>> work something like, SessionKey would first be "Default" but then
>>> ServiceTicket would re-define it, since it inherited it (and is
>>> higher
>>> up the chain) and change it to "Default from ServiceTicket".
>>>
>>> In this case, if I had:
>>>
>>> Dim objTempClass1 As new TempClass1
>>> Dim objServiceTicke t As new ServiceTicket
>>> Dim objAuthHeader As new AuthHeader
>>>
>>> objTempClass1.S essionKey = "Default from ServiceTicket" '
>>> Inherited from ServiceKey
>>> objServiceKey.S essionKey = "Default from ServiceTicket"
>>> objAuthHeader.S essionKey = "Default"
>>>
>>> But if I took out the Sessionkey from the ServiceKey class that it

would
>>> be:
>>>
>>> objTempClass1.S essionKey = "Default" '

Inherited
>>> from AuthHeader
>>> objServiceKey.S essionKey = "Default" '

Inherited
>>> from AuthHeader
>>> objAuthHeader.S essionKey = "Default"
>>>
>>> Also, I originally got this from a sample program that didn't set
>>> the
>>> defaults, but had it defined as:
>>> *************** *************** *************
>>> Public Class AuthHeader:Inhe rits SoapHeader
>>> Public AuthHeaderName As String
>>> Public SessionKey As String
>>> End Class
>>>
>>> Public Class ServiceTicket:I nherits AuthHeader
>>> Public IsAuthenticated As Boolean
>>> Public SessionKey As String
>>> Public Expiration As DateTime
>>> End Class
>>>
>>> Public Class TempClass1:Inhe rits ServiceTicket
>>> Public TomsClass1Name As String
>>> End Class
>>> *************** *************** ***********
>>>
>>> Is there any good reason to defining SessionKey again ServiceTicket?
>>>
>>> I assume since it always would inherit from AuthHeader, it would

always
>>> get SessionKey from the inheritance. If it wanted to set SessionKey

in
>>> ServiceTicket, it could just set it by:
>>>
>>> SessionKey = "Default"
>>>
>>> without needing to redefine it.
>>>
>>> Is this correct?
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>>
>>
>>
>
>



Apr 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3753
by: KK | last post by:
Windows Forms Inheritance, Incomplete? I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the application contains couople of forms which have a consistant look and also shares SOME similar functionality between the forms.
2
2203
by: KK | last post by:
** Posting it here cause after couple of days no body responded.** I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the application contains couople of forms which have a consistant look and also shares SOME similar functionality between the forms.
4
12822
by: Dave Theese | last post by:
Hello all, The example below demonstrates proper conformance to the C++ standard. However, I'm having a hard time getting my brain around which language rules make this proper... The error below *should* happen, but my question to the community is *why* does it happen? Any answer will be appreciated, but a section and paragraph number from the C++ Standard would be especially appreciated.
8
7832
by: __PPS__ | last post by:
Hello everybody, today I had another quiz question "if class X is privately derived from base class Y what is the scope of the public, protected, private members of Y will be in class X" By scope they meant public/protected/private access modifiers :) Obviously all members of the base privately inherited class will be private, and that was my answer. However, the teacher checked my answers when I handed in, and the problem was that I had...
22
23388
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete examples?
45
6368
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using parameters, I get CS1501 (no method with X arguments). Here's a simplified example which mimics the circumstances: namespace InheritError { // Random base class. public class A { protected int i;
6
2102
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself so, cannot be called a WebForm itself, the child pages will implement forms). I created a Master.aspx page and removed all HTML from it, added some code to the .aspx.vb file to add controls to my page. Then I created a Child.aspx and changed the...
5
2475
by: Noah Roberts | last post by:
Is there anything that says that if you virtually inherit from one class you have to virtually inherit from anything you inherit from?
3
1844
by: RSH | last post by:
I have a simple question regarding inheritance in a web form. I have a DropDownList in an aspx form. It is called DropDownList1 I have a class that will be overriding the render event so I have a snippet of this class: Public Class CustomDDL Inherits DropDownList
8
328
by: RSH | last post by:
Hi, I am working on some general OOP constructs and I was wondering if I could get some guidance. I have an instance where I have a Base Abstract Class, and 4 Derived classes. I now need to make a list class that will store the objects. My question is how do I go about creating the list class...I am assuming it should be a standalone class that uses an arraylist to store the objects. If I go that route how do I instantiate the...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.