Skip to content
Discussion options

You must be logged in to vote
  • 접근 가능 위치

    구분 선언한 클래스 내 상속받은 클래스 내 인스턴스
    private o x x
    protected o o x
    public o o o
  • 추상 클래스 (abstract)

    • 다른 클래스가 상속받을 수는 있지만, 새로운 인스턴스는 만들 수 없는 클래스
  • 추상 메서드

    • 추상 클래스 안에 만들 수 있는 메서드
    • 추상 클래스를 상속받는 모든 것들이 구현해야하는 메서드를 의미함
    • 메서드를 구현해서는 안되고 call signature만 작성해야 함
// 추상 클래스 : 상속 O, 새 인스턴스 생성 X
abstract class User {
    constructor(
        private fisrtName: string,
        private lastName : string,
        public nickName: string
    ) {}
// 메서드 : 구현 O
getFullName(){
    return `${this.fisrtName} ${this.lastName}`
}

// 추상 메서드 : 구현 X. call signature만 작성
abstract getNickName():void

}

// 추상 클래스를 상속받음
class Player extends User{
// 추상 메서드 구현
getNickName(){
return this.nickName
}
}

//…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by innerstella
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
More
Labels
1 participant