top | item 46184067

(no title)

Gupie | 2 months ago

Open a file in the constructor, close it in the destructor. RAII with 0 allocations.

discuss

order

dh2022|2 months ago

std::vector<int> allocated and freed on the stack will allocate an array for its int’s on the heap…

Gupie|2 months ago

Sure, but my point was that RAII doesn't need to involve the heap. Another example would be acquiring abd releasing a mutex.