C++ 상속 개념
![[C++] 상속](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbVbumi%2FbtqzYLBUgbk%2FAAAAAAAAAAAAAAAAAAAAAGwi7xqg6EsJ0ya-Q5HRFZyUigDbAaWDa8YSevArDKCh%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3Dmtra7%252BEobXc%252BeRdkU%252BKWm7NpZM4%253D)
[C++] 상속
1. 상속 #include #include class Professor { std::string name; int age; int major; }; class Student { std::string name; int age; int id; }; int main() { } 위의 코드에서 멤버 데이터인 name과 age가 중복되는것을 볼 수 있다. ① Student와 Professor의 공통의 특징을 모아서 Person 클래스를 설계한다. #include #include class Person { std::string name; int age; }; class Professor : public Person { int major; }; class Student : public Person { int id; }..