.NET: objects-types


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
15 views
As is known, during execution of the program, the CLR creates an in-memory object-types that contain including the method table.

Suppose there are two classes: Employee and Manager (the heir to the Employee). When you create an instance of the type Manager, a reference to the object-type indicates the object type Manager. When you call the instance Manager, the record of this method, the first is searched first in the method table of the object-type Manager, then Employee. However, Richter says that all objects-reference types object type type.

Then how is the relationship of types in the inheritance chain? I thought object-type Manager will refer the Employee, and the Employee in turn on Type. Or is there another mechanism involved?
by | 15 views

3 Answers

0 like 0 dislike
Can lapse into jargon, but the principle works something like this. There is such a thing as "virtual table". If the method is "virtual" (available for overriding), then it is stored in this table. Then when you override this method in the class of "heir" in this table is populated with the new address. And even if you use a link to refer to the base type, and in fact there is an heir to that of the base type, the method will be called heir, thanks to this table
by
0 like 0 dislike
The answer to a problem, but was wondering — in this connection a question arose?
by
0 like 0 dislike
Object-type isn't Type? He is not related to table methods, it is metadata.
by

Related questions

0 like 0 dislike
4 answers
asked Apr 12, 2019 by Akaero
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
27,912 users