[WIP] Add medium to hard C++ interview questions with detailed answers#1
Merged
amolpawarap merged 1 commit intomainfrom Apr 1, 2026
Merged
Conversation
Copilot stopped work on behalf of
amolpawarap due to an error
April 1, 2026 10:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
01-cpp-basics.md— C++ Basics (data types, pointers, references, memory management)02-oop-concepts.md— OOP Concepts (classes, inheritance, polymorphism, encapsulation, abstraction)03-stl.md— STL (vectors, maps, sets, iterators, algorithms)04-templates-and-generics.md— Templates & Generic Programming05-smart-pointers-and-modern-cpp.md— Smart Pointers & Modern C++ (C++11/14/17/20)06-concurrency-and-multithreading.md— Concurrency & Multithreading07-data-structures-and-algorithms.md— Data Structures & Algorithms08-design-patterns.md— Design Patterns09-common-coding-problems.md— Common Coding ProblemsREADME.md— Table of contents linking all filesOriginal prompt
Create a comprehensive set of medium to hard C++ interview preparation questions with detailed answers and push them as separate topic-wise
.mdfiles to the repositoryamolpawarap/cpp-preparation.Requirements
Each topic should be its own
.mdfile with 15-20 medium to hard level questions and detailed, well-explained answers including code examples where applicable.Files to create:
01-cpp-basics.md— C++ Basics (data types, pointers, references, memory management)constcorrectness, pointer arithmetic, dangling pointers, memory leaks, stack vs heap,new/delete,malloc/freedifferences, reference vs pointer,volatile,sizeofoperator, type casting (static_cast,dynamic_cast,reinterpret_cast,const_cast), undefined behavior, memory alignment, bitwise operations, lvalue vs rvalue.02-oop-concepts.md— OOP Concepts (classes, inheritance, polymorphism, encapsulation, abstraction)03-stl.md— STL (vectors, maps, sets, iterators, algorithms)mapvsunordered_map(red-black tree vs hash table),setvsmultiset,std::sortvsstd::stable_sort, custom comparators,std::priority_queue,std::dequeinternals,emplace_backvspush_back,std::movewith containers,std::algorithmusage (transform, accumulate, partition, etc.), iterator categories, allocators.04-templates-and-generics.md— Templates & Generic Programmingstd::enable_if, variadic templates, template metaprogramming,constexpr, CRTP (Curiously Recurring Template Pattern), type traits,decltype,autotype deduction, fold expressions, concepts (C++20).05-smart-pointers-and-modern-cpp.md— Smart Pointers & Modern C++ (C++11/14/17/20)unique_ptr,shared_ptr,weak_ptr, custom deleters,make_unique/make_shared, circular reference problem, move semantics, perfect forwarding,std::forward, rvalue references, lambda expressions (capture modes),std::optional,std::variant,std::any, structured bindings,if constexpr,std::string_view,noexcept,constexprfunctions, ranges (C++20), coroutines overview.06-concurrency-and-multithreading.md— Concurrency & Multithreadingstd::thread,std::mutex,std::lock_guard,std::unique_lock,std::condition_variable,std::atomic,std::async/std::future/std::promise, deadlock prevention, race conditions, producer-consumer problem, reader-writer problem, thread pool design,std::shared_mutex, memory ordering (memory_order_relaxed,memory_order_acquire,memory_order_release,memory_order_seq_cst),std::call_once, thread-safe singleton.07-data-structures-and-algorithms.md— Data Structures & Algorithms08-design-patterns.md— Design Patterns09-common-coding-problems.md— Common Coding ProblemsREADME.md— Update the existing README.md to serve as a table of contents linking to all the above files.Format for each question file:
Key Takeaways: