Hacker News new | ask | show | jobs
by exprx 3737 days 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.)

1 comments

Well, if everything is an object, I guess everything is an object.

Usually when people are talking about OO objects they mean data+behaviour.

> 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.

The 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.
Definitely, 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.
Object refers to a memory object, which could be data or text(functions).