Re: overriding,shadowing concept

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Sanjeeva (sanjeeva_at_proteans.com)
Date: 06/23/04


Date: Tue, 22 Jun 2004 20:46:51 -0700

Overriding or shadowing is same...

The difference between Override and Overload is

some method in the base class is overriden in the derived class without any
change in the function prototype or signature like this.

Class Base1{

    virtual protected DoSomething(){
        //stuff
    }
}

Class Derived1 : Base1{

    protected override DoSomething(){
        // different stuff.
    }
}

Overloading is in the same class defining defferent versions of the same
method based on the number and type of the parameter list.
Example like this..

Class SomeOne{
    public string GetInfo( int i ){
        //Some stuff
    }

    public string GetInfo( string s) {
        //Some stuff
    }

    public string GetInfo( int i, int j) {
        //Some stuff
    }

}

"sangam via .NET 247" <anonymous@dotnet247.com> wrote in message
news:u8UTYQrLEHA.1644@TK2MSFTNGP09.phx.gbl...
> (Type your message here)
> exact differences between overriding,shadowing,overloading
>
> --------------------------------
> From: s sangameshwaran
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>3XFrGLe3gE25wdH7Xp+nnw==</Id>



Relevant Pages

  • Re: overides/loads usage
    ... procedure in the derived class shadowing or overriding the new procedure ... parameters like one in base class and the other with two parameters. ... parameters shadowing or overriding the new in base class. ...
    (microsoft.public.dotnet.languages.vb)
  • overides/loads usage
    ... looking at is a derived class that has one constructor. ... i see that the base class has a new procedure with no arguments. ... parameters shadowing or overriding the new in base class. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Any one here knows if there is a way to prevent subclasses from overriding a method in superclas
    ... you'll not be able to call the base class one then. ... overriding private virtual functions stems from simple fact ... introduce a function into a derived class without checking to see if it ... matches a virtual function in one of the bases, ...
    (microsoft.public.vc.language)
  • Re: =?ISO-8859-1?Q?compare_two_structs_via_=3D=3D?=
    ... bool operator ==(string x, string y) ... I'm using the phrase "overload" as well. ... "Overriding" there is a mistake. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: function lookup
    ... and derived class member share the same name but are otherwise unrelated. ... The wrong overload can kick in. ... to prevent overriding a virtual function, which means you must check all ... inadvertently overriding a virtual function. ...
    (microsoft.public.vc.language)