Learn business

    [C++]new & delete

    malloc & free를 대신하는 new & delete 먼저 C언어의 malloc & free를 이용한 동적할당을 아래 코드로 살펴보자. #include #include #include #pragma warning(disable: 4996) using namespace std; char * MakeStrAdr(int len) { char * str = (char *)malloc(sizeof(char) * len); return str; } int main(void) { char * str = MakeStrAdr(20); strcpy(str, "I am so happy~"); cout