-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo7.ts
More file actions
37 lines (31 loc) · 906 Bytes
/
demo7.ts
File metadata and controls
37 lines (31 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// private protected public 访问类型
// public 允许我在类的内外被调用
// private 允许在类内被使用
// protected 允许在类内及继承的子类中使用
// class PersonA {
// public name: string; // 为何会报错呢??
// public sayHi() {
// this.name; // public内部调用没问题
// console.log("hi");
// }
// }
// const personA = new PersonA();
// personA.name = "dell";
// console.log(personA.name);
// class PersonA {
// // public name: string;
// constructor(public name: string) { // 加了public就代表注释的两句
// // this.name = name;
// }
// }
// const personA = new PersonA("dell");
// console.log(personA.name);
// class PersonA {
// constructor(public name: string) {}
// }
// class TeacherA extends PersonA {
// constructor(public age: number) {
// super("dell");
// }
// }
// const teacherA = new TeacherA(28);