Questions
C++ questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Declare a 2D Array with new in C++
Learn how to create dynamic 2D arrays in C++ using new, pointer syntax, and safer alternatives like std::vector.
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 Find the Length of an Array in JavaScript
Learn how to get an array's length in JavaScript, detect the end of an array, and avoid common mistakes with clear examples.
How to Format std::string Like sprintf in C++
Learn how to format strings in C++ using sprintf-style functions, std::string, and safer modern alternatives for file output.
How to Generate a Stack Trace in C++ with GCC When a Program Crashes
Learn how to capture stack traces in C++ with GCC, handle crashes on Linux, and understand portable crash reporting basics.
How to Get and Print a Variable Type in Standard C++
Learn how to inspect and print a variable's type in standard C++ using typeid, type traits, and practical compiler notes.
How to Get the Current Date and Time in C++
Learn how to get the current date and time in C++ using cross-platform standard library features and format the result clearly.
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 Initialize Private Static Data Members in C++
Learn how to declare and define private static data members in C++, avoid linker errors, and understand header vs source file rules.
How to Initialize std::vector with Hardcoded Values in C++
Learn the easiest ways to initialize a std::vector with hardcoded values in C++, including initializer lists, constructors, and common pitfalls.
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 Reach Peak Floating-Point Throughput on x86-64 Intel CPUs in C/C++
Learn why peak FLOPs per cycle are hard to reach on Intel x86-64 CPUs and how instruction throughput, latency, SIMD, and unrolling affect C/C++ code.
How to Read a File Line by Line with ifstream in C++
Learn how to read a text file line by line with ifstream in C++, including parsing coordinate pairs and avoiding common mistakes.
How to Read an Entire File into std::string in C++
Learn how to read a whole file into a std::string in C++ using ifstream, iterators, and streams with beginner-friendly examples.
How to Remove an Element from std::vector by Index in C++
Learn how to erase an element from std::vector by index in C++ using erase(), iterators, and safe bounds checks with clear examples.
How to Replace All Occurrences of a Character in std::string in C++
Learn how to replace every occurrence of a character in std::string in C++ using loops, std::replace, and 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 Split a String by a String Delimiter in C++
Learn how to split strings by a multi-character delimiter in C++ using standard library tools like find and substr.