Questions
C++ questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Convert std::string to const char* or char* in C++
Learn how to convert std::string to const char* or char* in C++, when to use c_str() or data(), and how to avoid common mistakes.
How to Declare an Interface in C++: Abstract Base Classes Explained
Learn how to create interfaces in C++ using abstract base classes, pure virtual functions, and virtual destructors with clear examples.
How to Implement the Singleton Design Pattern in C++ Correctly
Learn how to implement Singleton in C++ safely, avoid memory leaks, and understand modern alternatives like local static instances.
How to Iterate Over Words in a String in C++
Learn how to iterate over whitespace-separated words in a C++ string using stringstream, extraction operators, and clean loop patterns.
How to Learn C++ from Books: A Beginner-Friendly Guide to Choosing the Right C++ Book
Learn how to choose good C++ books by skill level, avoid bad resources, and build a practical C++ learning path with confidence.
How to Profile C++ Code on Linux
Learn how to profile C++ code on Linux to find slow functions, bottlenecks, and performance hotspots using practical examples.
How to Sleep for Milliseconds in C++
Learn how to pause a C++ program for milliseconds using modern C++ and POSIX-compatible options with clear examples.
How to Trim a std::string in C++ Safely
Learn how to trim whitespace from std::string in C++, including safe right-trim, left-trim, edge cases, and common patterns.
Improving Object Recognition Algorithms in OpenCV with Template Matching and Feature-Based Detection in C++
Learn how to improve OpenCV object recognition in C++ for scale, rotation, noise, occlusion, and false positives using practical techniques.
New Features in C++17: A Beginner-Friendly Guide
Learn the most important C++17 features, what changed from C++14, and how modern C++ compilers support them in practice.
Pointer vs Reference in C++: What’s the Difference?
Learn the difference between pointers and references in C++ with syntax, examples, mistakes, and practical use cases.
Pointers vs Objects in C++: Why Use a Pointer Instead of the Object Itself?
Learn when to use pointers vs objects in C++, how memory and ownership work, and why direct objects are often the better default.
Public vs Private vs Protected Inheritance in C++
Learn the difference between public, private, and protected inheritance in C++ with examples, use cases, common mistakes, and comparisons.
Sequence Points and Undefined Behavior in C and C++
Learn what sequence points mean in C and C++, how they relate to undefined behavior, and why expressions like a[++i] = i are unsafe.
The Rule of Three in C++: Copying Objects, Copy Constructor, and Copy Assignment
Learn the Rule of Three in C++: what object copying means, when to define copy operations, and how to prevent copying safely.
Undefined Reference and Unresolved External Symbol Errors in C and C++
Learn what undefined reference and unresolved external symbol errors mean in C and C++, their causes, fixes, and how to prevent them.
Underscores in C++ Identifiers: Rules, Reserved Names, and Safe Naming
Learn when underscores are allowed in C++ identifiers, which names are reserved, and how to choose safe member variable names.
What Are POD Types in C++? Plain Old Data Explained
Learn what POD types mean in C++, why they mattered, and how they relate to trivial and standard-layout types with simple examples.
What Are Smart Pointers in C++ and When Should You Use Them?
Learn what smart pointers are in C++, how they manage memory automatically, and when to use unique_ptr, shared_ptr, and weak_ptr.
What Cache-Friendly Code Means and How to Write It
Learn what cache-friendly code means, why memory access patterns matter, and how to write faster, cache-efficient programs.