ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` class Person{ // 属性 name:string; age:number; // 构造方法 constructor(name:string, age:number){ this.name = name; this.age = age; } // 方法 say():void{ console.log(this.name + " say ...."); } } class Student extends Person{ address: string; constructor(name:string, age:number, address:string){ // 必须有,放在最前面, 调用父类的构造方法 super(name, age); this.address = address; } getAddress():void{ console.log(this.address); } } var student = new Student("sn", 11, 'aa'); student.getAddress(); ```