virtual

  • The virtual keyword signifies that method and property can be overridden.
  • If the method of base class is not marked virtual, even then it can be overridden in derived class by marking it new.

    E.g.:    class Employee

    {

    protected double basic;

    protected double gross;

    public void CalcSal()

    {

    gross = basic + 0.5*basic;

    }

    }

    class Manager : Employee

    {

    protected double allowances;

    public new void CalculateSalary()

    {

    gross = basic + 0.5*basic + allowances;

    }

    }

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger