What Are Default Arguments in C++ Functions?
Default arguments let callers omit trailing parameters in C++. See the syntax, rules, pitfalls with overloads and a modern options struct alternative.
341 posts about C++: questions with answers, tutorials and articles, newest first.
Default arguments let callers omit trailing parameters in C++. See the syntax, rules, pitfalls with overloads and a modern options struct alternative.
See how C++ passes arguments by value, reference and pointer, with runnable examples and simple rules for choosing the right parameter type.
Define functions with a return type, name and parameters, declare them before use, and call them with arguments, with overloading and modern features.
Undefined behavior lets a C++ program do anything. See the common causes, why optimisers make it worse, and the tools and habits that prevent it.
Learn the four named C++ casts, when each is appropriate, and why they are safer and clearer than the C-style cast.
Declare and initialise arrays in C++, access elements safely, loop with range-based for and choose between built-in arrays, std::array and std::vector.
Compare plain enum with enum class in C++, including scoping, implicit conversion, fixed underlying types and flag sets, with working examples.
See how break, continue and goto change control flow in C++, with runnable examples, nested loop behaviour and safer alternatives to goto.
Compare the for, while, do-while and range-based for loops in C++, see when each one fits and avoid common mistakes like off-by-one errors.
Learn how C++ chooses between code paths with if, else and switch, including fall-through, braces in cases and the C++17 if initialiser.
Operator precedence in C++ decides which operator runs first and associativity breaks ties. Learn the table, the common traps and when to add parentheses.
Bitwise operators in C++ work on individual bits. See what &, |, ^, ~, << and >> do, and how to use masks to set, clear, toggle and test flags.
A beginner guide to C++ operators: arithmetic, relational and logical operators with examples, integer division, short-circuit evaluation and precedence.
Float is 32-bit and double is 64-bit in C++. See precision, range, literal suffixes, comparison pitfalls and a clear rule for choosing between them.
Fixed-width integer types such as std::int32_t give exact sizes on every platform. See when to use them, how to print them and which mistakes to avoid.
Learn the C++ integer types, why their sizes depend on the platform, how to check them with sizeof, and how signed and unsigned overflow differ.
A beginner guide to std::cout and std::cin: printing values, reading numbers and lines with getline, validating input and formatting output.
Learn how a C++ compiler error is built, why the first message matters most, and how to fix common syntax, type and linker errors step by step.
A clear comparison of C++11, C++14, C++17, C++20 and C++23 with the main features of each standard and advice on which one to compile with.
A practical guide to the g++ compiler flags you will use every day: standards, warnings, optimisation, debugging and linking.