nakka soft world !

동적 메모리 할당 본문

프로그래밍언어/C++

동적 메모리 할당

nakka 2017. 3. 14. 19:52
728x90

동적 메모리 할당


#include <iostream>

#include <stdlib.h>

using namespace std;


int main()

{

int* p1 = (int *)malloc(sizeof(int));

free(p1);


int* p2 = new int;

delete p2;


int* p3 = new int[10];

delete p3; // 버그

delete[] p3; // OK


}

728x90

'프로그래밍언어 > C++' 카테고리의 다른 글

reference  (0) 2017.03.15
namespace  (0) 2017.03.15
delete function, suffix return type, trailing return  (0) 2017.03.14
function template  (0) 2017.03.14
inline function  (0) 2017.03.14
Comments