This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one. Each
class has some varibles that need to be reset from time to time, so I have
created a method call "Clear" that does that. So my question is when using
"Clear" in an instance of class two, the clear method in Class one does not
get called, is there some way of excucting both "Clear" Methods in a single
call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel
pretty foolish when someone points it out, but it sure has me stumped at the
moment...
Thank you,
David
Public Class1
dim mQty as integer
dim mPrice as double
Public Sub Clear
mPrice = 0
mQty =0
end sub
Public Property Price as Double
Get
return mPrice
end get
Set(ByVal Value as Double)
mPrice = Value
end set
end property
Public Property Qty as Integer
Get
return mQty
end get
Set(ByVal Value as Integer)
mQty = Value
end set
end property
end class
Public Class2
inherits Class1
dim mInvoice as integer
Public Shadows Sub Clear
' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS
METHOD RUN THE CLEAR METHOD OF CLASS1?
mInvoice = 0
end sub
Public Property Invoice as Integer
Get
return mInvoice
end get
Set(ByVal Value as Integer)
mInvoice = Value
end set
end property
end class
i 12 1230
If I understand you have the two classes both with Clear methods. If you
call the Class2.Clear simply (depending on the language used) add a call to
the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear()
For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message
news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one.
Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when
using "Clear" in an instance of class two, the clear method in Class one does
not get called, is there some way of excucting both "Clear" Methods in a
single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped at
the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING
THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
If I understand you have the two classes both with Clear methods. If you
call the Class2.Clear simply (depending on the language used) add a call to
the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear()
For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message
news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one.
Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when
using "Clear" in an instance of class two, the clear method in Class one does
not get called, is there some way of excucting both "Clear" Methods in a
single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped at
the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING
THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
What about calling it from the "child class"?
Thanks.
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:rU***************@news04.bloor.is.net.cable.r ogers.com... If I understand you have the two classes both with Clear methods. If you call the Class2.Clear simply (depending on the language used) add a call
to the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear() For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one. Each class has some varibles that need to be reset from time to time, so I
have created a method call "Clear" that does that. So my question is when using "Clear" in an instance of class two, the clear method in Class one does not get called, is there some way of excucting both "Clear" Methods in a single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to
feel pretty foolish when someone points it out, but it sure has me stumped at the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
What about calling it from the "child class"?
Thanks.
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:rU***************@news04.bloor.is.net.cable.r ogers.com... If I understand you have the two classes both with Clear methods. If you call the Class2.Clear simply (depending on the language used) add a call
to the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear() For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one. Each class has some varibles that need to be reset from time to time, so I
have created a method call "Clear" that does that. So my question is when using "Clear" in an instance of class two, the clear method in Class one does not get called, is there some way of excucting both "Clear" Methods in a single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to
feel pretty foolish when someone points it out, but it sure has me stumped at the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
I think thats w Lloyd Sheen meanth
cl1
public sub clear()
'code
end sub
cl2 : cl1
public sub clear()
MyBase.Clear()
'code
end sub
hope it helps
eric
"D Miller" <de**********@yahoo.com> wrote in message
news:MD*****************@newsread1.news.pas.earthl ink.net... What about calling it from the "child class"? Thanks.
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in
message news:rU***************@news04.bloor.is.net.cable.r ogers.com... If I understand you have the two classes both with Clear methods. If
you call the Class2.Clear simply (depending on the language used) add a call to the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear() For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one. Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when using "Clear" in an instance of class two, the clear method in Class one
does not get called, is there some way of excucting both "Clear" Methods in a single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped
at the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
I think thats w Lloyd Sheen meanth
cl1
public sub clear()
'code
end sub
cl2 : cl1
public sub clear()
MyBase.Clear()
'code
end sub
hope it helps
eric
"D Miller" <de**********@yahoo.com> wrote in message
news:MD*****************@newsread1.news.pas.earthl ink.net... What about calling it from the "child class"? Thanks.
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in
message news:rU***************@news04.bloor.is.net.cable.r ogers.com... If I understand you have the two classes both with Clear methods. If
you call the Class2.Clear simply (depending on the language used) add a call to the Clear in the parent class.
For VB.NET the syntax is MyBase.Clear() For C# it is base.Clear();
Lloyd Sheen
"D Miller" <de**********@yahoo.com> wrote in message news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one. Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when using "Clear" in an instance of class two, the clear method in Class one
does not get called, is there some way of excucting both "Clear" Methods in a single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped
at the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
D Miller,
In addition to the other's comments I would recommend NOT using Shadows
here, I would recommend making Clear Overridable.
Making Clear Overridable will allow Class2.Clear to execute if you put a
Class2 object in a Class1 variable. If you left Class2.Clear Shadows, only
Class1.Clear would be called... Public Class Class1
Public Overridable Sub Clear mPrice = 0 mQty =0 end sub
end class
Public Class Class2 inherits Class1
Public Overrides Sub Clear
MyBase.Clear() mInvoice = 0 end sub
end class
Then you will be able to do:
Dim c As Class1() = New Class2()
c.Clear()
And Class2.Clear will be called, which will call Class1.Clear.
I tend to reserve Shadows for upgrade situations where the base method is
introduced that is not compatible with a derived method & a couple of other
specialized cases...
Hope this helps
Jay
"D Miller" <de**********@yahoo.com> wrote in message
news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one.
Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when
using "Clear" in an instance of class two, the clear method in Class one does
not get called, is there some way of excucting both "Clear" Methods in a
single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped at
the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING
THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
D Miller,
In addition to the other's comments I would recommend NOT using Shadows
here, I would recommend making Clear Overridable.
Making Clear Overridable will allow Class2.Clear to execute if you put a
Class2 object in a Class1 variable. If you left Class2.Clear Shadows, only
Class1.Clear would be called... Public Class Class1
Public Overridable Sub Clear mPrice = 0 mQty =0 end sub
end class
Public Class Class2 inherits Class1
Public Overrides Sub Clear
MyBase.Clear() mInvoice = 0 end sub
end class
Then you will be able to do:
Dim c As Class1() = New Class2()
c.Clear()
And Class2.Clear will be called, which will call Class1.Clear.
I tend to reserve Shadows for upgrade situations where the base method is
introduced that is not compatible with a derived method & a couple of other
specialized cases...
Hope this helps
Jay
"D Miller" <de**********@yahoo.com> wrote in message
news:QL****************@newsread1.news.pas.earthli nk.net... This may be a basic question, but it sure has me stumpted..
I have two classes, Class1 and Class2. Class 2 inherits class one.
Each class has some varibles that need to be reset from time to time, so I have created a method call "Clear" that does that. So my question is when
using "Clear" in an instance of class two, the clear method in Class one does
not get called, is there some way of excucting both "Clear" Methods in a
single call... See the code below for what I mean...
There must be a simple way of doing this, and I suspect I'm going to feel pretty foolish when someone points it out, but it sure has me stumped at
the moment...
Thank you, David
Public Class1 dim mQty as integer dim mPrice as double
Public Sub Clear mPrice = 0 mQty =0 end sub
Public Property Price as Double Get return mPrice end get Set(ByVal Value as Double) mPrice = Value end set end property
Public Property Qty as Integer Get return mQty end get Set(ByVal Value as Integer) mQty = Value end set end property end class
Public Class2 inherits Class1 dim mInvoice as integer
Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING
THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0 end sub
Public Property Invoice as Integer Get return mInvoice end get Set(ByVal Value as Integer) mInvoice = Value end set end property end class
i
I figured it would be something simple, thanks!
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de... "D Miller" <de**********@yahoo.com> schrieb Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0
mybase.Clear
end sub -- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
I figured it would be something simple, thanks!
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de... "D Miller" <de**********@yahoo.com> schrieb Public Shadows Sub Clear ' HERE IS WHERE THE QUESTION IS. IS THERE SOME WAY OF HAVING THIS METHOD RUN THE CLEAR METHOD OF CLASS1? mInvoice = 0
mybase.Clear
end sub -- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Jones |
last post by:
I'm sure the solution may be obvious, but this problem is driving me
mad. The following is my code:
class a(object):
mastervar =
def __init__(self):
print 'called a'
|
by: km |
last post by:
Hi all,
In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ?
thanks in...
|
by: Steve Jorgensen |
last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling
a particular case of implementation inheritance that would be easy and obvious
in a fully OOP language, but is not at...
|
by: majid |
last post by:
How can i write classes with multiple inheritance
|
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...
|
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...
|
by: Kevin Newman |
last post by:
I have been playing around with a couple of ways to add inheritance to a
JavaScript singleton pattern. As far as I'm aware, using an anonymous
constructor to create a singleton does not allow any...
|
by: Dave Rahardja |
last post by:
Since C++ is missing the "interface" concept present in Java, I've been using
the following pattern to simulate its behavior:
class Interface0
{
public:
virtual void fn0() = 0;
};
|
by: Jess |
last post by:
Hello,
I've been reading Effective C++ about multiple inheritance, but I
still have a few questions. Can someone give me some help please?
First, it is said that if virtual inheritance is...
|
by: Leo Seccia |
last post by:
Hello everyone,
I have a c# project with a sql server database.
I have a number of lookup tables in my database which I successfully managed
to import into my LINQ dataclasses.
eg.
Table:...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |