Designing Classes and Modules in C++ After Ten Years: Insights from Real Project Structures

Designing Classes and Modules in C++ After Ten Years: Insights from Real Project Structures

From WeChat Official Account: Programmer Cat In my first year of writing C++, I thought “as long as it runs, it’s fine”; by the third year, I started to emphasize “encapsulation, inheritance, and polymorphism”; it wasn’t until the tenth year that I realized: designing a good class and module is far more challenging than just … Read more

C++ Programming Guidelines – Class Design

C++ Programming Guidelines - Class Design

01 Class Design A class is the foundation of object-oriented design. A good class should have a single responsibility, a clear and concise interface, low coupling between classes, high cohesion within the class, and effectively demonstrate encapsulation, inheritance, polymorphism, and modularity.02 Single Responsibility of Classes Explanation: A class should have a single responsibility. If a … Read more

Mastering the Essence of C++ Class Design: static and const Methods

Mastering the Essence of C++ Class Design: static and const Methods

Series: In-Depth C++ Advanced Programming 🤔 Do You Really Understand static and const? // 😵 Common Confusing Code class ConfusingClass { private: static int count; // Does this need to be defined outside the class? const int value; // Can this be initialized outside the constructor? static const int MAX; // Can this be initialized … Read more