Modern C++ (C++11 and later) transformed how practitioners write the language. This track teaches C++17 patterns—not C-style C++ from the 1990s.
Key modern features (preview)
autotype deduction — less verbose iterator code- Range-based for loops — iterate containers cleanly
- Smart pointers —
std::unique_ptr,std::shared_ptrfor RAII heap ownership - Move semantics — transfer resources without deep copies
- Lambdas — inline function objects for algorithms
constexpr— compile-time computation where possible
Prefer STL over raw C patterns
std::vector<int> nums = {1, 2, 3};
for (int n : nums) { /* ... */ }
Use std::vector and std::string instead of raw arrays and char* in new code unless interfacing with C APIs.
Important interview questions and answers
- Q: What is RAII?
A: Resource Acquisition Is Initialization—bind resource lifetime to object lifetime so destructors clean up automatically (files, mutexes, heap memory). - Q: auto pitfalls?
A: auto deduces types from initializers—watch for unintended copies vs references; use explicit types when clarity matters.
Self-check
- Name one C++11 feature that reduces raw pointer use.
- Why prefer std::vector over C arrays in new code?
Tip: Prefer std::vector and smart pointers in new code—avoid writing C-with-classes style when STL solves the problem.
Interview prep
- What is RAII?
Resource Acquisition Is Initialization—bind resource lifetime to object scope via constructors and destructors.
- auto pitfalls?
auto deduces from initializers—unintended copies happen without & or const &; use explicit types when clarity matters.