1개월 전 · Jun 25, 2026 10:06 AM
Resource management in Modern C++:
- Rule of Zero: If your class uses standard RAII types (
std::string,std::vector,std::unique_ptr), do NOT declare a custom destructor, copy constructor, copy assignment, move constructor, or move assignment. Let the compiler synthesize all five automatically! - Rule of Five: If your class manages a raw system resource directly (OS socket, raw pointer, file handle), you must explicitly implement or delete all five special member functions to ensure proper ownership semantics.