Encapsulation of structure in class [closed] - c++

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Is it good practice to encapsulate a structure used by a class inside the class if only the class uses it and not the user who will end up using the class, or does it not matter?

It is generally poor practice to expose any internal details in the headers.
See GotW #100: Compilation Firewalls for more details.

Related

Where to place Clojure Specs? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
If you use Clojure Spec, how do you use it?
Do you tend to put all your specs in one place or distribute them through the "modules" of your program?

When should I use the "superproject" pattern? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Some libraries, such as LLVM, use a "superproject" pattern, where consumers of the library, such as libcxx, should live inside of the libraries' folder-structure. In the case of LLVM, this is llvm/projects.
This seems quite limiting, as it makes it harder use the library when there are other folder-structure constraints.
Why was this descision made, and what are some reasons to use such a layout?

why a protected member is allowed in a C++ class marked as final? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
A similar question has been already asked in stackoverflow regarding Java.
But C++ does not behaves exactly as Java and, in particular, C++ does not allow access on protected members of a class "...from another package...".
So, what is the rational to allow protected members inside class marked as final ? Is a convenient way for the developer to quickly switch a class from final to non final (if the design change) ?

Is there still a place for plain enums? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have started using strongly typed enums. Looking through my current project there are a few places were I still prefer plain enums.
If the strongly typed characteristic is unneeded and the enum is being used for its implicit conversion to int, are there any other tradeoffs that would make conventional enums a bad choice?

Should all classes that aren't inherited be final? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Should I declare all classes that aren't inherited as final even if they don't have anything to do with inheritance and that kind of stuff?
A class should be declared final when you want to declare the statement "this class cannot be inherited". This is not the same case as the statement "this class is not inherited". It is a matter of opinion but I would not forbid the inheritance of a class, unless there is a very specific reason to do so. Therefore, I would not declare a class final unless there was a reason to do so.
Hope I helped!