이미 할당된 메모리 공간에 객체를 생성할 때 사용하는 c++ 문법

 

new (pointer) Type(constructor_args)

pointer : 객체를 생성할 메모리 주소

Type: 생성할 타입

constructor_args: 생성자 인자

 

placement new는 delete와 연결되지 않기 때문에, 메모리 해제는 별도로 해줘야 한다.

pointer->~Type();

 

'공부 > C\C++' 카테고리의 다른 글

c++ 중괄호 초기화 Brace initialization  (0) 2025.07.13
c union  (0) 2025.07.05
c 매크로 - 함수형 매크로 ()  (0) 2025.06.28
c++ using typedef 차이  (0) 2025.06.28
c 매크로 - ## (토큰 결합 연산자)  (0) 2025.06.28

+ Recent posts