flutter中的继承
作者:互联网
super
class Person { int age; string name; Person(int age, String name){ this.age = age; this.name = name; } void sayhi(){ print('my name is' this.name) } } class Worker extend Person{ int salary; Worker(int age, string name, int salary) : super(age, name){ //super表示要继承父类的属性 this.salary = salary; } @override //告诉编译器和程序员他是一个重写覆盖父类的方法 void sayhi(){
super.sayhi() //表示调用父类的sayhi方法 print('my salary is'+ this.salary) } }
标签:salary,name,继承,age,sayhi,int,super,flutter 来源: https://www.cnblogs.com/xhrr/p/11357452.html