C++ Notes: Const Correctness and Immutability Design

C++ Notes: Const Correctness and Immutability Design

Master the correct usage of the const keyword, establish a mindset for immutability design, improve code quality and safety, and avoid common pitfalls in const usage. 🎯 Use Cases • API Design: Provide const guarantees for function parameters and return values • Class Design: Distinguish between const and non-const member functions • Thread Safety: Use … Read more

Differences Between C and C++

Differences Between C and C++

Although C and C++ are often mentioned together, they are certainly not the same thing.The C language we commonly use today is based on the C89 standard, while C++ is based on the C++99 standard.C89 was established in 1989, and the latest standards are C11 and C++11.Depending on the different standards, their functionalities also vary, … Read more

Differences Between C and C++

Differences Between C and C++

Although C and C++ are often mentioned together, they are certainly not the same thing.The C language we commonly use today is based on the C89 standard, while C++ is based on the C++99 standard.C89 was established in 1989, and the latest standards are C11 and C++11.Depending on the different standards, their functionalities also vary, … Read more

Function Overloading and Default Arguments in C++

Function Overloading and Default Arguments in C++

Function Overloading and Default Arguments in C++ In C++ programming, functions are an important way to organize code, encapsulating specific functionalities into independent modules. To enhance the flexibility and readability of the code, C++ provides two powerful and commonly used features: Function Overloading and Default Arguments. This article will detail the concepts, usage, and examples … Read more

Simple Python Calls to C++ Programs

Methods for Python to Call C/C++ Programs Recently, while debugging, I encountered a situation where Python was running very slowly, so I researched methods to embed C++ programs in Python. I am documenting this for future reference. Generally, calling C/C++ programs from Python can be divided into three steps: 1. Write the C/C++ implementation program. … Read more

Detailed Explanation of Overloading in C++

Detailed Explanation of Overloading in C++

If we create two or more members with the same name but different numbers or types of parameters, this is called C++ overloading. In C++, we can overload: Methods Constructors Index properties This is because these members only have parameters. Types of Overloading in C++: Function Overloading Operator Overloading Function Overloading in C++ Function overloading … Read more

C++ Default Parameters vs Function Overloading: How to Choose?

C++ Default Parameters vs Function Overloading: How to Choose?

Imagine you are ordering a cup of milk tea 🧋… “Boss, I want a cup of pearl milk tea!” “Do you want to adjust the sweetness and ice level?” “No, the default is fine!” This scene seems very familiar, right? In the programming world, C++ default parameters are like the “standard configuration” at a milk … Read more

Function Overloading in C++ for Embedded Development

Function Overloading in C++ for Embedded Development

It has been a whole week since I last shared knowledge about C++, and I miss you all dearly! Now, let me briefly introduce today’s main topic: function overloading. What is function overloading? Function overloading is somewhat different from the concept of overloading in real life. Those who have a background in C may know … Read more