1 | class Person { |
或者1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25class Person {
name:string;
age: number;
constructor(name:string, age:number){
this.name = name;
this.age = age;
}
print () {
return this.name + ':' + this.age;
}
}
class Student extends Person {
school:string;
constructor (school: string) {
super('cc', 19);
this.school = school;
}
point() {
return this.name + ':' + this.age + ':' + this.school;
}
}
var S = new Student('清华');
s.print(); // cc:19:清华