Creating Objects in C++ Using () and {}

In C++, there are subtle semantic differences between creating objects using () and {}. The differences mainly lie in the initialization rules and applicable scenarios. 1. Using () to Initialize Objects This method is known as function-style initialization or parentheses initialization, used for constructor calls or type conversions. #include <iostream> #include <vector> int main() { … Read more

A Detailed Explanation of C++ Comments

What are C++ Comments? C++ comments are explanatory text added by programmers in the code to clarify the functionality, purpose, or specific implementation details of the code.The compiler completely ignores comments, which are only meaningful to human readers. The Two Main Forms of Comments 1. Single-line Comments (//) Start with double slashes <span>//</span> and end … Read more

C++ Practice [GESP2506 Level 2] Power Sum Numbers

GESP Level 2 practice, loops and enumeration, difficulty beginner. CCF-GESP C++ Assessment Standards Hong Yang, WeChat Official Account: Hong Yang’s Programming Class CCF-GESP C++ Assessment Standards Comprehensive Guide – [GESP2506 Level 2] Power Sum Numbers Problem Requirements Problem Description For a positive integern, if n can be expressed as the sum of two powers of … Read more

Learning C++ from Scratch Day 4 (Switch Statement) – The Most Comprehensive and Easy-to-Understand Guide

The basic syntax of the switch statement is as follows: switch (expression) { case constant_expression1: code1; break; case constant_expression2: code2; break; …… default: codeN; } ①The switch statement in C++ is used to select different code branches based on the value of the expression. ②The expression inside switch (expression) can only be of integer, character, … Read more

From Non-Technical Mechanical Engineering to C++: Securing a 17K Salary!

About the Author Hello everyone, I am a member of the C++ Embedded Development cohort 2., I graduated in 2024 from a non-prestigious university with a degree in Mechanical Engineering, and I am currently working in Shenzhen as a C++ software developer with a salary of 17K. I decided to switch to programming in my … Read more

C++ Conditional and Loop Control: if Statement

if Statement The if statement is used to execute some code when a condition is true. Syntax: if (condition) { // Executes when the condition is true} The condition is the expression to be evaluated. If the condition is true, the statements within the braces will be executed. If the condition is false, the code … Read more

Jolt Physics: A High-Performance Physics Engine in Modern C++

🚀 Jolt Physics: A “High-Performance Physics Engine” in Modern C++ Have you encountered the following problem while developing 3D games, simulation systems, or virtual reality applications: “I need a fast, stable, and easy-to-use physics engine to handle collisions, gravity, and rigid body motion, but Bullet is too complex, and ODE has limited functionality. What should … Read more

C++ Practice [GESP2506 Level 1] Duty

GESP Level 1 Practice, Conditions and Logic, Beginner Difficulty. CCF-GESP C++ Assessment Standards Hong Yang, WeChat Official Account: Hong Yang’s Programming Class CCF-GESP C++ Assessment Standards Comprehensive Guide – [GESP2506 Level 1] Duty Problem Requirements Problem Description Little Yang and Little Hong are on duty, responsible for cleaning the classroom. Little Yang is on duty … Read more

The Misconception of C++ Vector Doubling Capacity Strategy

In C++, <span>std::vector</span> is a dynamic array that can automatically adjust its capacity at runtime as needed. Many beginners believe that the capacity growth strategy of <span>std::vector</span> is simply “doubling” (i.e., each time it expands to twice its original size), but this is not the case. The fact is, the C++ standard does not specify … Read more

C/C++ Array and Pointer Traps

In C/C++, arrays and pointers are fundamental and powerful tools, but they are also often sources of programming errors. Because they can be interchangeable in certain situations (such as when passing function parameters), developers can easily confuse their essence, leading to various “traps”. Here are some common traps of arrays and pointers, along with brief … Read more