class Person {
public name: string;
public age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
speak(): void {
console.log(`${this.name}今年${this.age}岁了`);
}
}
let xiaoming = new Person('小明', 16);
xiaoming.speak();
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |