Friend Functions and Object-Oriented Design: Examining C++ Design Philosophy from the Essence of Encapsulation

Abstract One of the core principles of Object-Oriented Programming (OOP) is encapsulation, which binds data and methods that operate on the data into classes, hiding internal implementation details and interacting with the outside only through public interfaces. The friend function in C++ is often criticized for being able to directly access a class’s private and … Read more

Understanding C++ Classes and Objects Through ‘Playing Games’: An Introductory Lesson on Object-Oriented Programming

Many beginners in C++ often feel confused: “What exactly are classes and objects? How do they differ from the procedural approach of C language?” In fact, you don’t need to memorize concepts rigidly; you can easily understand the core logic of object-oriented programming through something we do every day – “playing games”. Today, I will … Read more

How to Write Object-Oriented C Language?

In embedded system development, the C language dominates due to its proximity to hardware, efficiency, and portability. Although C is a procedural programming language, we can fully implement the core features of Object-Oriented Programming (OOP) through some programming techniques: encapsulation, inheritance, and polymorphism. Traditional C code has limitations, such as difficulty in managing global state, … Read more

Rust Learning Plan – Day 6: Structs and Methods

Day 6: Structs and Methods (struct & impl)。Today, we will give your code some “shape” and “behavior”—Rust’s structs and methods are similar to Python’s classes, but lighter and more rigorous. Day 6 Learning Plan (Approx. 1–2 hours) Learning Objectives • Define and use structs (<span>struct</span>) • Implement methods (<span>impl</span> block) • Understand the relationship between … Read more

Introduction to C++ Classes and Objects

Introduction to C++ Classes and Objects

1. Preliminary Understanding of Procedural and Object-Oriented ProgrammingThe C language is procedural, focusing on processes, analyzing the steps to solve problems, and gradually solving problems through function calls.●C++ is object-oriented, focusing on objects, breaking down a task into different objects, and completing it through interactions between objects.2. Introduction to Classes●In C language, a structure can … Read more

Why Do Embedded Software Developers Prefer to Encapsulate Source Code into Libraries?

Why Do Embedded Software Developers Prefer to Encapsulate Source Code into Libraries?

I am Lao Wen, an embedded engineer who loves learning.Follow me to become even better together! 1. Benefits of Encapsulating into Libraries If a device program is perfectly encapsulated into a library, it means: 1. The cost for all engineers to port or create the device driver is minimal. 2. As the number of users … Read more

Introduction to Object-Oriented Programming in Embedded C++

Introduction to Object-Oriented Programming in Embedded C++

Follow our official account to keep receiving embedded knowledge! 1. Comparison of Object-Oriented and Procedure-Oriented Programming Imagine you want to build a house. Procedure-Oriented: It’s like you are doing everything yourself. Your thinking is linear: “First, I will move bricks -> then mix cement -> next, build walls -> finally, put on the roof.” You … Read more

Learning Python – Object-Oriented Programming (OOP)

Learning Python - Object-Oriented Programming (OOP)

Object-Oriented Programming (OOP) is a programming paradigm that uses “objects” to design software and applications. Let’s delve into understanding Object-Oriented Programming in Python. 1. Core Concepts of Object-Oriented Programming 1. Class and Object Class: A blueprint or template for objects, defining the properties and methods of the object. Object: An instance of a class, having … Read more

Fundamentals of Object-Oriented Programming in C

Fundamentals of Object-Oriented Programming in C

What is Object-Oriented Programming (OOP) Object: Girlfriend, Boyfriend, Entity (an individual of a class of things) Type: Classification, Category The four main characteristics of Object-Oriented Programming: Abstraction: Abstracting things, abstracting properties, abstracting behaviors Properties: Common characteristics of a class of things, e.g., humans: age, name, ID, gender… Behaviors: Common behaviors of a class of things, … Read more