3 ms·
A struct is an object. Even a plain integer is an object, considering the referred article was talking about C++. (Yes, you cannot inherit all kinds of objects
by exprx 11y ago
A struct is an object. Even a plain integer is an object, considering the referred article was talking about C++.
(Yes, you cannot inherit all kinds of objects – but you definitely can inherit any kind of struct, POD or not.)
- rfrey 11y agoWell, if everything is an object, I guess everything is an object. Usually when people are talking about OO objects they mean data+behaviour.
- jschwartzi 11y agoObject refers to a memory object, which could be data or text(functions).
- mcphage 11y ago> when people are talking about OO objects they mean data+behaviour The distinction between behavior being "a set of methods defined inside a class", and "a set of methods whose first param is a particular type of struct" is not that important.
- nlawalker 11y agoThe distinction between "a set of methods with privileged access to encapsulated internal state of a class" and "a set of functions whose first param is a particular type of struct, and operate on members of that struct that everyone can access" is pretty critical though.
- mcphage 11y agoDefinitely, and encapsulation is one of the good things you get out of well designed OO. But I don't think it's that relevant in regards to objects as data+behavior, and while it leads to much better designs, I don't think it's required—hence all of the C libraries written in a very OO style. So: yes, but not really relevant to the point being discussed.