[C++언어] 상속이란? 예제로 살펴보기(Inheritance)


[C++언어] 상속이란? 예제로 살펴보기(Inheritance)

목차 [C++언어] 상속이란? 상속이란 부모 클래스(Base Class)와 자식 클래스(Derived Class) 두개의 클래스가 있을 때 자식 클래스에서 부모 클래스의 method 나 attribute를 물려 받아서 동일하게 가지는 것을 의미 합니다. 상속은 : (콜론)을 사용해서 전달 합니다. : (콜론)으로 상속 정의 정의된 클래스의 속성과 메소드를 가져옴 [C++언어] 상속 예제 코드>> #include #include using namespace std; class family { public: string address = "Seoul"; }; class son : public family { public: int olds = 16; }; int main() { son James; cout


원문링크 : [C++언어] 상속이란? 예제로 살펴보기(Inheritance)