a class with an abstract method cannot be instantiated (that is, we cannot create an instance by calling it) unless all of its abstract methods have been defined in subclasses. Although this requires more code and extra knowledge, the potential advantage of this approach is that errors for missing methods are issued when we attempt to make an instance of the class, not later when we try to call a missing method. This feature may also be used to define an expected interface, automatically verified in client classes.

如果在父类中使用@abstractmethod,那么子类中必须明确定义这个abstract method才能实例化,否则会报错。

使用@abstractmethod的优点是,避免子类在编程过程中漏掉必要的method

Java 中也有类似方法。

最新文章

  1. ActionContext.getContext().getSession()
  2. XAMPP 的安装配置(Linux 版)
  3. 点/边 双连通分量---Tarjan算法
  4. Android网络编程系列 一 TCP/IP协议族之传输层
  5. WinDBG使用之线程
  6. Javascript兼容和CSS兼容总结
  7. 数据的存储-NSKeyedArchiver和write to file介绍
  8. Android Studio 实时显示布局文件Preview窗口
  9. Tomcat配置虚拟路径访问容器外的硬盘资源
  10. FastReport编程方式给Picture控件赋值
  11. 关于使用阿里OSS服务搭建图床和使用PicGO上传图片到图床
  12. Integer 比较忽略的问题
  13. hihoCoder week13 最近公共祖先·一
  14. Win下Eclipse提交Hadoop程序出错:org.apache.hadoop.security.AccessControlException: Permission denied: user=D
  15. 【BZOJ】3453: tyvj 1858 XLkxc 拉格朗日插值(自然数幂和)
  16. NEXYS 3开发板练手--USB UART(三)
  17. css3和jquery实现的可折叠导航菜单(适合手机网页)
  18. Centos 6.4 python 2.6 升级到 2.7一起的MySQLdb不能使用的解决问题
  19. Java 程序员容易犯的10个SQL错误
  20. spring运用的设计模式

热门文章

  1. UE4开发PSVR游戏的常见问题
  2. 虚拟机安装linux遇到的问题
  3. VS2015发布web服务
  4. EhCache缓存框架的使用
  5. The server time zone value 'EDT' is unrecognized or represents more than one time zone
  6. 测开之路七十六:性能测试蓝图之html
  7. 阅读笔记06-架构师必备最全SQL优化方案(2)
  8. DbWrench002--建模以及数据正向工程和反向工程的具体操作
  9. < 备考CET6 - 作文模板句 - 话题:重要性/做选择 >
  10. 认识requests库,以及安装方法