# 修飾符
```
public 公開的,在任何地方都可以訪問
protected 受保護的,只能在當前類和當前類的子類內部使用
private 私有的,當前類的內部使用
```
## 1.普通寫法
```
class Person{
pubilc userName:string
pubilc userAge:number
constructor( name:string,age:number ){
this.userName = name;
this.userAge = age;
}
}
new Person('hello',3)
```
## 2.抽象類 abstract:不可以實例化
```
abstract class {
abstract connection():void;
}
//一般用在框架中,實際項目應用較少
//使用場景:例如封裝一個鏈接數據庫的約束類,這個類不實現具體功能,
//但是需要鏈接每一款數據庫和其中的函數操作
abstract class Db{
abstract connection():void;
abstract auth():void;
}
class mySql extends Db{
connection(){
}
auth(){
}
}
new mySql();
```