超级和子类函数调用 [英] Super and sub classes function calling

查看:87
本文介绍了超级和子类函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

堆栈溢出是癌症。看起来这个地方也是癌症。我认为程序员很聪明。



我尝试过:



ulu kuk lul

解决方案

因此非常简单:

1.创建一个新的子类 object

2.调用该对象的 displayResult 方法:

2.1。打印消息从子类显示

2.2。调用父类的 displayResult 方法。



注意:首次创建对象时不执行任何代码,除了由编译器创建的默认构造函数。


stack overflow was cancer. looks like this palce is cancer too. i thought programmers were smart lul.

What I have tried:

ulu kuk lul

解决方案

It is fairly straightforward thus:
1. Create a new subclass object
2. Call the displayResult method of that object which:
2.1. Prints the message "Displaying from subClass"
2.2. Calls the displayResult method of the parent class.

Note: no code is executed when the object is first created, apart from the default constructor(s) created by the compiler.


这篇关于超级和子类函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆