In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how C++ organizes relevant data to form structures or classes". Many people will encounter this dilemma in the operation of actual cases. then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
C.1: organize related data to form structures or classes
Reason (reason)
Ease of comprehension. If data is related (for fundamental reasons), that fact should be reflected in code.
Reduce the difficulty of understanding. If the data (for fundamental reasons) are relevant, then this fact should be reflected in the code.
Translator's note: the first step of object-oriented software design is to model the target system. It is a whole in the target system, and it should be the same in the model.
Example (sample)
Void draw (int x, int y, int x2, int y2); / / BAD: unnecessary implicit relationshipsvoid draw (Point from, Point to); / / betterNote (note)
A simple class without virtual functions implies no space or time overhead.
Simple classes that do not contain virtual functions do not incur additional space and time costs.
Note (Note)
From a language perspective class and struct differ only in the default visibility of their members.
From a language point of view, the only difference between class and struct is the visibility of members by default.
Translator's note: this is only the difference at the compilation level.
Enforcement (implementation recommendations)
Probably impossible. Maybe a heuristic looking for data items used together is possible.
It's probably impossible. Perhaps it is possible to heuristically look for data to be used together.
This is the end of the content of "how C++ organizes relevant data to form structures or classes". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.