using System;namespace ConsoleApplication1
{
public class father
{
public virtual void a()
{
Console.WriteLine("a");
}
}
public class child: father
{
public void c()
{
Console.WriteLine("c");
} public override void a()
{
base.a ();
Console.WriteLine("d");
} } class Class1
{
static void Main(string[] args)
{
father aa = new father();
aa.a();
child bb = new child();
bb.c();
bb.a();
father dd =new child();
dd.a();
//child ff = new father();
//ff.a();
Console.ReadLine();
}
}
}
小弟不才,请问各位高手
father dd =new child(); 这句话的意思是什么?
注释掉的地方为什么会报错?
base.a (); 这句又是指什么呢请各位高手不吝赐教
解决方案 »
- 求助
- 怎么向同一datagridview中添加不同数据源的数据?
- 通过usb口(com)打开GPS设备(高分)
- 如何能让datagrid的记录能修改的同时,不能添加呢?
- 如何禁止键盘操作. 急急
- System.Management; 命名空间在.Net FrameWork SDK 2.0中是什么 ?
- 关于在自定义控件中使用嵌入到资源里的图片的问题
- 18位数字转日期的问题
- 关于winform的MVP模式
- Webform下,想用Timer可是有两个Timer:System.Threading.Timer和System.Timers.Timer,哪个适合?我是要做网页游戏用的。
- ultraGrid 数值型字段排序问题
- 如何把global.asax加入到系统中
还有,你的问题在这里出现N次了,都让人麻木了
==
调用基类的a方法
father dd =new child();这里是父类实例化子类 正确的child ff = new father();子类是不能实例化父类的 所以错误