• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    해결됨

상속 질문 있습니다

19.09.18 14:14 작성 조회수 92

0

class Base {

public:

 int x;

};

class Derived : Base {

};

상속받은 Derived옆에 Base의 접근지정자를 쓰지 않으면

private으로 접근지정자가 들어가는건가요?

접근지정자를 쓰지않아도 오류가 뜨지않는걸 보니 자동으로 뭔가가 들어가는거 같아요

답변 1

답변을 작성해보세요.

1

맞습니다. 기본이 private입니다.

If you use class to define your class, the default access specifier will be private. (I think it's wrong, too.) If you use struct, however, it will be public.

https://stackoverflow.com/questions/4796789/default-inheritance-access-specifier