반응형 객체지향1 [Java] Inheritance vs Delegation (상속과 위임) 객체지향 프로그래밍에서 클래스를 설계할 때 상속(Inheritance)과 위임(Delegation) 방식을 고민하게 된다. 상속(Inheritance)과 위임(Delegation) 방식의 차이점과 어떤 상황에서 뭘 써야할지에 대해 알아보자. 클래스의 상속(Inheritance) 객체지향 프로그래밍 언어에서 클래스를 상속(Inheritance)을 통해 정의할 수 있다. class Person { protected int age; protected String name; public Persion(int age, String name) { this.age = age; this.name = name; } public int getAge() { return this.age; } public String getN.. 2019. 7. 2. 이전 1 다음 반응형