⚙️
Q1. unique_ptr vs shared_ptr?
A. unique_ptr is single ownership and movable; shared_ptr is reference-counted shared ownership (overhead, cycles possible).
Mid
⚙️
Q2. What is move semantics?
A. Transferring resources from temporaries instead of copying, using move ctor/assignment and std::move.
Mid
⚙️
Q3. Rule of 3/5/0?
A. If you define destructor/copy ops, likely define all. Add move ops. Prefer Rule of 0 using RAII types.
Mid
⚙️
Q4. vector vs list?
A. vector is contiguous and cache-friendly; list has high overhead and poor cache locality.
Mid
⚙️
Q5. What is iterator invalidation?
A. Operations may invalidate iterators/references (e.g., vector reallocation). Know rules to avoid UB.
Mid
⚙️
Q6. What is object slicing?
A. Copying derived object into base by value drops derived parts. Prefer refs/pointers for polymorphism.
Mid
⚙️
Q7. What is constexpr?
A. Enables compile-time evaluation when possible, improving performance and correctness.
Mid
⚙️
Q8. What is template specialization?
A. Providing a specific implementation for a template for certain types/values.
Mid