473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

difference between ME and MYCLASS

Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in the
context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?

Thank you.
Alex.
Mar 10 '06 #1
4 1313
Radu,

An answer from a guy who seldom is beside it in this kind of questions.

http://groups.google.com/group/micro...7b6507718c418f

I hope this helps,

Cor
Mar 10 '06 #2

Radu wrote:
Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in the
context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?


Me does refer to the current object - the object in question (obj) is a
Child! What you are seeing is overriding working as intended...

--
Larry Lard
Replies to group please

Mar 10 '06 #3
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb
Radu,

An answer from a guy who seldom is beside it in this kind of
questions.

http://groups.google.com/group/micro...7b6507718c418f

I hope this helps,

Cor


Good to have a big archive and somebody who can search it. I would have had
no immediate answer (really). :)
Armin

Mar 10 '06 #4
Thank you all ! It helped !:-)))

Alex.
"Radu" <RE***************************@yahoo.com> wrote in message
news:Zq********************@b2b2c.ca...
Hi. I have the following question:

Since the methods are virtual, the following code produces "Child other
stuff" - the call runs as if pasted in Child... it runs in Parent but in
the context of Child.
-------------------------------
Module Module1

Sub Main()
Dim obj As New Child()
obj.DoSomething()
End Sub

End Module
-------------------------------
Public Class Parent

Public Sub DoSomething()
OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------
Public Class Child
Inherits Parent

Public Overrides Sub OtherStuff()
MsgBox("Child other stuff")
End Sub

End Class
----------------------------------

Therefore, to avoid this, we have to change parent using MYCLASS....

-------------------------------
Public Class Parent

Public Sub DoSomething()
MyClass.OtherStuff()
End Sub

Public Overridable Sub OtherStuff()
MsgBox("Parent other stuff")
End Sub

End Class
-------------------------------

I'm confused as to what exactly is the difference between ME and MYCLASS -
why doesn't ME work in this case ? ME should refer to the current object,
(Parent, in this case), correct ?

Thank you.
Alex.

Mar 10 '06 #5

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

Similar topics

32
by: Mario Fratelli | last post by:
MyClass *p = new MyClass; MyClass *p = new MyClass(); do they mean something different? Thanks a lot, Mario Fratelli.
11
by: modemer | last post by:
If I define the following codes: void f(const MyClass & in) {cout << "f(const)\n";} void f(MyClass in) {cout<<"f()\n";} MyClass myclass; f(myclass); Compiler complain that it can't find...
5
by: Gunnar G | last post by:
What is the difference between the two lines in the main function? class MyClass{ ....}; int main(){ MyClass a(); MyClass a; }
1
by: Iced Crow | last post by:
What is the difference between using MyClass and Me inside of inherited classes?
7
by: guy | last post by:
Stirring up trouble here;) why is it that C# programmers try and denigrate VB.NET while VB.NET developers seem to have no problem with C# but just prefer VB.NET? I use both and this generally seems...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.