Warning: Undefined array key 0 in /www/wwwroot/w/show/success.php on line 261

Warning: Trying to access array offset on value of type null in /www/wwwroot/w/show/success.php on line 261
_higrid.net-嗨网
当前位置:嗨网首页>书籍在线阅读

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

Warning: Undefined array key 0 in /www/wwwroot/w/show/success.php on line 266

Warning: Trying to access array offset on value of type null in /www/wwwroot/w/show/success.php on line 266

Warning: Undefined array key 0 in /www/wwwroot/w/show/success.php on line 266

Warning: Trying to access array offset on value of type null in /www/wwwroot/w/show/success.php on line 266

10.4.1 抽象类和抽象方法

简单地说,用来描述共性的类就是抽象类,抽象类中不考虑具体实现,只确定必须具有的行为,即确定抽象方法。如教师的任务是教学,具体教什么,如何教,每个教师都有自己独特的一面,对教学这个动作就可以提取出来作为抽象方法,而不考虑具体实现内容。包含抽象方法的类就是抽象类。抽象类和抽象方法声明使用abstract关键字,语法如下。

<访问修饰符> abstract class 抽象类名
{        //类体
<访问修饰符> abstract 返回类型 方法();        //抽象方法
}

例如,声明了有一个抽象方法Display方法的抽象类 Employee。

01  public abstract class Employee 
02  {
03          public  abstract void Display();  //抽象方法Display 
04  }


Warning: Undefined array key 0 in /www/wwwroot/w/show/success.php on line 276

Warning: Trying to access array offset on value of type null in /www/wwwroot/w/show/success.php on line 276

Warning: Undefined array key 0 in /www/wwwroot/w/show/success.php on line 276

Warning: Trying to access array offset on value of type null in /www/wwwroot/w/show/success.php on line 276