标签:java 面向 code 结合 开放性 alert const let 开放
class People { constructor(name) { this.name = name } saySomething() { } } class A extends People { constructor(name) { super(name) } saySomething() { alert(‘I am A‘) } } class B extends People { constructor(name) { super(name) } saySomething(){ alert(‘I am B‘) } } let a = new A(‘a‘); a.saySomething(); let b = new B(‘b‘); b.saySomething();
比如saySomething,定义了一个方法,但是在子类中可以实现不同的功能
标签:java 面向 code 结合 开放性 alert const let 开放
原文地址:https://www.cnblogs.com/wzndkj/p/11706687.html