Re: Equals() and inheritance



On Nov 26, 2:16 pm, Alex Cohn <AlexC...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
In C++, inheritance works through a virtual table. Each object refers to a
table of virtual functions. The overloaded Equals() for object of type B is
in the object's table. Therefore, even if the object is "known" to the
compiler as type A reference, the call will peform the B::Equals() call. I am
puzzled if C# resolves all overloads at compile time.

You're confusing overloading and overriding. Overriding is performed
at execution time, but overloading is performed at compile time. I
believe C++ works the same way.

Jon
.



Relevant Pages

  • Re: Function Overloading
    ... There can be some nasty "ambiguous overloading" bugs. ... It's usually some overhead at run-time (although this point may ... Overloading is fully resolved at compile time. ... overload resolution rules -- although it is never totally ...
    (comp.lang.c)
  • Re: optional argument versus subroutine overloading
    ... Overloading is typically resolved at compile time. ... subroutine call at all. ... wouldn't repeat the test in the middle of a time critical loop inside of ...
    (comp.lang.fortran)
  • Re: polymorphism/boxing question
    ... there's no boxing involved in your examples. ... overloading is performed at compile time. ... doesn't hobble polymorphism, however, which is more about *overriding* ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Python syntax in Lisp and Scheme
    ... but overloading only works at compile time: ... > doesn't work if you're using a base class pointer for all your derived ... I think that the point was that the overload resolution rules can handle the ...
    (comp.lang.python)
  • Re: Python syntax in Lisp and Scheme
    ... >> compiles and runs without complaint. ... > Ahh, but overloading only works at compile time: ...
    (comp.lang.python)