C++/Tips

[C++] New_2

메리사츠 2021. 6. 21. 18:45

1. New

=> New는 C++에서 동적할당을 하기 위한 연산자

=> Hep Segment에 저장됨

=> https://merry-nightmare.tistory.com/279

 

[c++] new 연산자

1. Memory => 메모리에는 Code / Data / Stack / Heap 등이 존재 [https://merry-nightmare.tistory.com/264] Program이 실행 되면 PAS(Process Address Space가 Memory에 할당 => Program -> Process -> Memory..

merry-nightmare.tistory.com

 

2. Heap에 생성되지 않는 Class(new) 생성

=> Operator new를 오버로딩 하고, Class 내에 Public이 아닌 Private로 생성함

class A
{
private:
    void* operator new(size_t size)
    {
    	void* address = new char[size];
        return address;
    }
}