C++ MCQ
Test your C++ knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
What is the correct file extension for a C++ source file?
2Which header file must be included to use cout in C++?
3What does cout stand for?
4What is the correct syntax to define a variable of type integer?
5What is the entry point of a C++ program?
6What does the :: operator represent in C++?
7What is a pointer in C++?
8What is the difference between & and * when declaring variables?
9What is a reference in C++?
10Which keyword allocates memory on the heap in C++?
11What is function overloading in C++?
12What keyword is used to define a class in C++?
13What is the default access specifier for members of a class?
14What is a destructor?
15What does the virtual keyword do?
16What is a pure virtual function?
17What does the const keyword on a member function mean?
18What is a template in C++?
19What is the STL?
20What is a vector in C++?
21What does #include do?
22What is the difference between stack and heap memory?
23What is a namespace?
24What does endl do?
25What is the size of a bool in C++?
26What is operator overloading?
27What is a copy constructor?
28What is the this pointer?
29What is inheritance in C++?
30What does the delete operator do?
31What is the difference between struct and class in C++?
32What is a static member in C++?
33What does the inline keyword suggest for a function?
34What is the range-based for loop syntax in C++11?
35What is a nullptr?
36What does auto mean when declaring a variable in C++11?
37What is the purpose of the const qualifier on a variable?
38What is function call by reference?
39What is a string in C++?
40What is a memory leak?
What is RAII (Resource Acquisition Is Initialization)?
2What is a smart pointer?
3What is the difference between unique_ptr and shared_ptr?
4What is a move constructor?
5What are lvalue and rvalue in C++?
6What is std::move?
7What is template specialization?
8What is the vtable?
9What is the Rule of Five in C++11?
10What is SFINAE?
11What does std::enable_if do?
12What is perfect forwarding?
13What is a lambda expression in C++11?
14What is constexpr?
15What is std::optional?
16What is structured bindings (C++17)?
17What is a variadic template?
18What is the purpose of weak_ptr?
19What is undefined behavior in C++?
20What does the noexcept specifier do?
21What is copy elision?
22What is the std::string_view (C++17)?
23What is an initializer list (std::initializer_list)?
24What does decltype do?
25What is the difference between const int* and int* const?
26What is SFINAE and how does std::void_t simplify it?
27What is the std::span type?
28What is the std::ranges library (C++20)?
29What is the Pimpl (Pointer to Implementation) idiom?
30What is fold expression in C++17?
31What is if constexpr in C++17?
32What is a designated initializer (C++20)?
33What is the three-way comparison operator <=> (spaceship)?
34What is std::expected (C++23)?
35What is CRTP used for beyond static polymorphism?
36What are C++20 concepts used for vs SFINAE in terms of readability?
37What is coroutine_handle in C++20?
38What is the co_yield expression in C++20?
39What is std::jthread and how does it differ from std::thread?
40What is exception safety in C++ and what are the three guarantees?
What is template metaprogramming (TMP)?
2What are C++20 concepts?
3What are C++20 coroutines and how do they differ from C++ threads?
4What is the memory ordering model in C++11 atomic operations?
5What is type erasure in C++?
6What is the Curiously Recurring Template Pattern (CRTP)?
7What is the One Definition Rule (ODR)?
8What is placement new in C++?
9What is std::variant and when is it preferred over union?
10What are C++20 modules and how do they differ from header files?
11What is the std::allocator_traits and custom allocator pattern?
12What is the difference between deep in the compile pipeline between constexpr and consteval?
13What is Address Sanitizer (ASan) in C++?
14What is undefined behavior sanitizer (UBSan)?
15What is the aliasing rule and its impact on compiler optimization?
16What is the ISO C++ hidden friend pattern?
17What is std::pmr (polymorphic memory resources, C++17)?
18What is Structured Binding Declarations interaction with custom types (C++17)?
19What is the Itanium C++ ABI and why does it matter?
20What is the "as-if" rule in C++ optimization?