Sunday, December 11, 2011

Abstract Classes and Concrete Classes

Abstract classes are the classes those are not complete. They should be derived so that becomes usable. Some members of the abstract class does not know its implementation and the derived class can implement them to complete the purpose of the base class.

In contrast, Concrete classes have full implementation of their purpose.

abstract class EmployeeBase
    public int ID { get; set; }
    public string Name { get; set; }
    public double BasicPay { get; set; }
    public abstract double CalcSalary();

class Clerk: EmployeeBase
    public override double CalcSalary()
        double HRA= BasicPay * .40;
        double DA= BasicPay * .25;
        double PF= BasicPay * .12;
        return BasicPay + HRA + DA - PF;

No comments:

Post a Comment