简体   繁体   中英

how to organize the large number of class members?

Suppose for a C++ class, there are 100 or even 1000 class private members of different types or classes. What's the neat way to organize that? It's not a good practice to scroll down/up the screen to do any operations.

Thanks so much!

Basically one .h file should include just one class. But you can include nested class for instance. Then you can put the implementation in as many .cpp files as you want. Each file should be grouped into directories.

However you should consider a refactoring of your design if you have:

  • too high level of abstraction, (classes too generic hence many methods).
  • overuse of inheritance against aggregation.

This situations causes code bloat, that is more code than you really need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM