//代码清单w5-9
public class CountClass 
{
    public int count; 

    public CountClass(int startValue)  		// 构造函数
    {
        count = startValue;
    }

    public virtual int StepUp()
    {
        return ++count;
    }
}

class Count100Class : CountClass 
{
    public Count100Class(int x) : base(x)  	//构造函数
    {
    }

    public override int StepUp()
    {
        return ((base.count) + 100);
    }
}
 
class TestCounters
{
    static void Main()
    {
        CountClass counter1 = new CountClass(1);
        CountClass counter100 = new Count100Class(1);

        System.Console.WriteLine("Count in base class = {0}", counter1.StepUp());
        System.Console.WriteLine("Count in derived class = {0}", counter100.StepUp());
    } 
}
