What you need to override a function in .NET.

I was asked about this in an interview today, and I just can’t understand. Everyone asked me from the beginning to advanced questions, but this one popped up. I described inheritance and polymorphism, and then this question arose. Obviously, I never tried to override each method in the [C # / C ++] class, but I did not know that there was anything that was required to override a particular method (for example, .ToString). Am I misinterpreting the question or is something needed? And if so, what makes this demand?

+3
source share
5 answers
  • base class should not be sealed
  • the method in the base class should be marked as virtualorabstract
+9
source

, , virtual abstract ( ). , - .

+1

++ # virtual. , , .

+1

, , abstract.

0

, , , , . #, :

  public override double parentFunction() 
  {
     //child implementation
  }

... .

Without hearing verbatim verbatim, it is difficult to say what the interviewer was looking for. My experience with interviewers is that they just want to make sure that you understand the generalities, but who knows. I would be interested to know if you get a job :) Good luck!

0
source

All Articles