Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 1
    It's probably also worth noting that it was probably easier to have classes and structures work the same under the hood, than to have them be fundamentally different. There might in retrospect have been some benefit to e.g. specifying that anything declared as a struct must be a PODS (i.e. forbidding structs from having virtual members, non-trivial default constructors or destructors, etc.) but such a thing has not to my knowledge ever been required by any C++ standard nor implementation. Commented Dec 16, 2013 at 17:25
  • 1
    @supercat the fact that it was an OO language in which a vast repertoire of programs written in a non-OO language were valid programs, brought the concept to the fore, and it does seem to come up more there than in more purely OO languages (and of course is actually defined in the standard). The history of early C++ definitely explains a lot about it. Stroustrup's "The Design and Evolution of C++" is an interesting read. Commented Dec 16, 2013 at 21:08
  • 1
    I perceive a religious war between people who feel that everything which isn't "oop-ish", should be, and those who think that OOP should be regarded as a tool, but not the tool. C++ certainly seems to embrace the latter philosophy, but I really don't know much about languages before it. My own philosophy is that when one wants an object one should use an object, and when one wants an aggregation of related but independent variables, one should use that. C++ makes no syntactic distinction between those kinds of things, and .NET tries to blur that distinction, but the little I know of D... Commented Dec 16, 2013 at 22:06
  • 1
    ...suggests that it recognizes it moreso than C++ or .NET. Aggregations of variables aren't exactly OOPish, but that doesn't mean they shouldn't be employed when they're useful. Commented Dec 16, 2013 at 22:10
  • 4
    I disagree with "C has structs, it has no concept of encapsulation, so everything is public.", You can hide a definition of a struct inside a *.c-File and let other translations units only use it with a pointer. So you have a even stronger encapsulation, because other translations units do not even know what is inside the struct. Commented May 8, 2017 at 11:35