On Sunday, August 3, 2025 5:29:46 AM Mountain Daylight Time Mike Parker via Digitalmars-d-learn wrote: > Classes and structs in C++ are both value types, and instances of > both are referred to as objects. This isn't unusual. > > An object is a concrete instance of a type described by a class > or struct definition. It's the thing you're manipulating, not the > definition. Whether you're manipulating it directly or through a > reference makes no difference. Whether it's on the stack or the > heap makes no difference. > > Consider that a pointer to a struct a reference to the struct > instance in the same way a class variable is a reference to a > class instance.
Exactly. I don't think that I've ever seen anyone claiming before that a an instance of a struct should not be considered an object. An object is an instance of any class or struct, and inheritance has nothing to do with it. And really, the whole concept that D has with structs vs classes is somewhat unique. C# has something similar (though IIRC, it's not quite the same), whereas in C++, the only difference between a struct and a class is what the default visibility level of its members are (public for structs and private for classes). And from what I've seen, most languages have just gone with classes. Glancing at Rust, it looks like they just went with structs, but I'm not very familiar with Rust, so I don't know the details. But either way, what exactly a class or struct is in a given language very much depends on that language. Some of the concepts are pretty universal, but the details can be quite different. So, talking about structs vs classes in a general sense rather than when talking about a specific language isn't very useful IMHO. Similarly, you'll get arguments over whether inheritance is a core part of object-oriented programming or not. Personally, I would have said that having a struct or class which has member functions - and therefore instances of that struct or class are objects with functions associated with them - would be the core of what it means for object-oriented programming and that inheritance was an extension of it and not a requirement, whereas some people would argue that inheritance is a core requirement of object-oriented programming. As I understand it, Smalltalk had a very different form of object-oriented programming than what folks normally think of today, and it was one of the first (if not the first) OO language, but many folks these days think of Java's form form of OO when they think of OO, which is probably why some folks think that OO must have inheritance in a manner similar to Java. And the reality of the matter is that pretty much every language uses such terms in its own way which may or may not match what other languages use those terms for. So, if you want to talking about a concept such as an object or object-oriented programming, then you're going to tend to get a lot of comparing and contrasting between languages, sometimes with someone trying to claim that a particular language doesn't really qualify, because it doesn't fit how they use the term (which was probably strongly influenced by whichever languages they've used the most). - Jonathan M Davis