许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

类的继承


using System;

class horse
{
    
public virtual string run()
    
{
        
return ("horse run");
    }

}


class qianliHorse:horse
{
    
public override string run()
    
{
            
return ("Qian li horse run");
    }


}


class HanxueHorse:qianliHorse
{
//    public override string run() //注释此处会怎样?
//    {
//            return ("Hanxue horse run");
//    }

    
public new string run()
    
{
            
return ("NEW Hanxue horse run");
    }

}


class myApp
{
    
static void Main_83()
    
{
        HanxueHorse h 
= new HanxueHorse(); //替换horse为HanxueHorse如何    
        Console.WriteLine(h.run());
    }

}

/*
NEW Hanxue horse run
 * 
*/

posted on 2007-11-30 15:29  许明会  阅读(120)  评论(0)    收藏  举报