How do you think about memory ownership and resource management on a fast-moving team, and when is a raw pointer still acceptable?

Last updated 21 June 2026

  • Default to RAII (tie each resource to an object whose destructor releases it) and encode ownership in types: std::unique_ptr for single ownership, std::shared_ptr only when truly shared, std::weak_ptr to break cycles.

  • Raw pointers are acceptable only as non-owning handles (observing parameters, optional rebindable references) whose pointee is guaranteed to outlive them. Never manage them with manual new/delete.

  • A clear team rule (owners hold smart pointers, APIs borrow via raw pointers or references) lets reviewers spot leaks and dangling pointers at a glance.

  • https://utkrusht.ai/blog/cplusplus-interview-questions
  • https://roadmap.sh/questions/cpp
  • https://internshala.com/blog/cpp-coding-interview-questions/
All C++ interview questions