Questions

C++ questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Why Variables Can't Be Declared Directly After a case Label in C++ switch Statements

Learn why C++ blocks variable declarations after case labels in switch statements and how to fix it with braces and scope.

cppswitch-statement

Why Virtual Functions Matter in C++: Polymorphism Explained

Learn why virtual functions are needed in C++, how overriding really works, and when dynamic dispatch matters in inheritance.

cpppolymorphismvirtual-functions

Why `+ 0.1f` Can Be Faster Than `+ 0` in C++: Compiler Optimization and Floating-Point Behavior

Learn why changing `0.1f` to `0` can slow C++ code dramatically due to compiler optimizations, floating-point math, and loop removal.

cppperformancevisual-studio-2010compilation

Why `while (!stream.eof())` Is Wrong in C++ iostreams

Learn why `while (!stream.eof())` is a bug in C++ iostream loops, what to use instead, and how it compares to `scanf(...) != EOF` in C.

cppiostreamc++-faq

Why enum class Is Safer Than Plain enum in C++

Learn why C++ enum class is safer than plain enum, with type-safety examples, scoping rules, comparisons, and practical usage tips.

cppenumstype-safetyenum-class

constexpr vs const in C++: What’s the Difference and When to Use Each

Learn the difference between constexpr and const in C++, when to use each one, and how compile-time constants differ from read-only values.

cppc++11constantsconstexpr

push_back vs emplace_back in C++: What’s the Difference?

Learn the difference between push_back and emplace_back in C++, when each constructs or moves objects, and how to use them correctly.

cppc++11stdmove-semantics

std::endl vs \n in C++: Difference, Performance, and When to Use Each

Learn the difference between std::endl and \n in C++, when flushing happens, performance impact, and which one to use in real code.

cppiostreamc++-faq

std::string vs std::wstring in C++: Differences, Unicode, and When to Use Each

Learn the difference between std::string and std::wstring in C++, including ASCII, Unicode, wide characters, and when to use each.

cppstringunicodec++-faq

typename vs class in C++ Templates: What’s the Difference?

Learn the difference between `typename` and `class` in C++ template parameters, including nested templates and when `typename` is required.

cpptemplateskeyword

Page 6 of 6 - 110 questions