static_cast와 reinterpret_cast 예제로 본 차이
#include "stdafx.h" #include <stdio.h> class shape{ private: int a; public: virtual void draw() { printf("share::draw() \n"); } }; class rect : public shape { private: int b; public: rect() { b = 30; } void draw() { printf("rect::draw() \n"); } void onlyRect() { printf("rect::onlyRect() \n"); } }; int _tmain(int argc, _TCHAR* argv[]) { int arData[] = {1,2,3,4}; int * ptr = static_cast<int *>(arData); char * pStr = "ABC"; ptr = static_cast<int *>(pStr); // error C2440: 'static_cast' : 'char *'에서 'int *'(으)로 변환할 수 없습니다. rect rcTest; shape * pShare = static_cast<shape *>(&rcTest); // upcast pShare->draw(); shape parent; rect * pRect =...