473,399 Members | 2,159 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,399 software developers and data experts.

Unexpected behaviour of MyClass (please ignore 1st post)

Public Class Base
Public Function Foo() As String
Return MyClass.GetType.FullName
End Function

End Class

Public Class Derrived
Inherits Base
End Class

Why does Derrived.Foo() return "Derrived"? Shouldn't that be "Base"?
Nov 21 '05 #1
2 908
"Diana Mueller" <no@spam> schrieb:
Public Class Base
Public Function Foo() As String
Return MyClass.GetType.FullName
End Function

End Class

Public Class Derrived
Inherits Base
End Class

Why does Derrived.Foo() return "Derrived"? Shouldn't that be "Base"?


If you instantiate 'Derived' and call 'Foo' on this object, the object's
most specific type is 'Derived', and thus "Derived" is returned.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Diana,

Because you are doing a methnod which is in MyClass which returns the type
of the current instance and not from the used class

Than it would have been
Gettype(Base).FullName

I hope this helps,

Cor
Nov 21 '05 #3

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

Similar topics

6
by: velthuijsen | last post by:
I've created a class MyClass { public: MyClass(); MyClass(int); MyClass& operator=(const MyClass& Right); ... private: ...
2
by: Gerhard Esterhuizen | last post by:
Hi, I am observing unexpected behaviour, in the form of a corrupted class member access, from a simple C++ program that accesses an attribute declared in a virtual base class via a chain of...
13
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to remember a report a little while ago about tsearch v2...
9
by: Jeff Louie | last post by:
In C# (and C++/cli) the destructor will be called even if an exception is thrown in the constructor. IMHO, this is unexpected behavior that can lead to an invalid system state. So beware! ...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
7
by: Andrew McLean | last post by:
I have a bunch of csv files that have the following characteristics: - field delimiter is a comma - all fields quoted with double quotes - lines terminated by a *space* followed by a newline ...
2
by: Filimon Roukoutakis | last post by:
Dear all, I have a MyClass.h file with declarations and MyClass.cxx file with definitions. From this I create a library libMyLib.a, containing properly the MyClass.o object. When I try to link...
6
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I found a really strange quirk in the C# compiler, which I can't beleive is proper behaviour. If I define a class thus: public class MyClass { public override string ToString() { return...
3
by: swethak | last post by:
hi, i create the one file.At time of creation i insert below contents into the file &lt;?php include("ClassName.class"); $myclass = &new ClassName; echo $myclass->myfunction1(); ?&gt;
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.