type cast1 타입 캐스팅 정리 업캐스팅파생 클래스의 객체를 기본 클래스의 포인터로 가리키는 것쉽게 말해, 자식 클래스 객체를 부모 클래스의 포인터로 가리키는 것파생 클래스의 객체를 기본 클래스 객체처럼 다룰 수 있다.#include #include using namespace std;class Circle // 기본 클래스{public: int radius;public: void setRadius(int r) { radius = r; } void showRadius() { cout setRadius(100); cout getArea() getArea(); // 오류 발생 /* cBase는 Circle 클래스의 포인터이므로 cBase 포인터로는 Circle 클래스 멤버만 접근할 수 있다. 그러므로 getAr.. 2025. 2. 6. 이전 1 다음