September 2019
Beginner
512 pages
12h 52m
English
In addition to the implicit inheritance to the Object type, Dart allows us to extend defined classes by using the extends keyword, where all of the members of the parent class are inherited, except the constructors.
Now, let's check out the following example, where we create a child class for the existent Person class:
class Student extends Person { String nickName; Student(String firstName, String lastName, this.nickName) : super(firstName, lastName); @override String toString() => "$fullName, also known as $nickName";}main() { Student student = new Student("Clark", "Kent", "Kal-El"); print(student); // same as calling student.toString() // prints Clark Kent, also known as Kal-El}
The following observations can be made ...
Read now
Unlock full access