D
D
Denis Bredun2020-07-15 21:43:57
C++ / C#
Denis Bredun, 2020-07-15 21:43:57

What happens under the hood when we hide a derived class method?

When we declare a method virtual, then at compilation a new entry is placed in the method records table, in which a flag is placed, what kind of method this method is (virtual, instance or static), but how is it marked under the hood that the method is hidden? I did not find any information about this from Goldstein or Richter.

class A
{
 public void DoSmth()
 {

 }
}
class B : A
{
 public new void DoSmth()
 {

 }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-07-15
@freeExec

For two weeks now you have been asking about all sorts of "underhood" that in everyday life has not given up to anyone.
How many of your own programs have you already written? How many had to be rewritten because of the newly acquired knowledge? What is the payoff? When will you start collecting information yourself? Is it difficult to compile the code and see how it is "under the hood"?

IL_0000: nop
IL_0001: newobj instance void B::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: callvirt instance void A::DoSmth()
IL_000d: nop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question