Which of these statements about objects is true?

c++, object

Solution

Many of these answers have ignored the C++ tag. In C++, "an object is a region of storage. [Note: a function is not an object, regardless of whether or not it occupies storage in the same way that objects do.]" (The C++ Standard, 1.8/1).

If the homework question is about C++, then no other definition of object is applicable, not even "anything that is visible or tangible and is relatively stable in form" (dictionary.reference.com). It's not asking for your opinion about OOP principles, it's in effect asking whether ix and ia are variables.

Since it's homework I'll not tell you the answer, but do note that `struct { int x; } ix;` is not the same thing as `struct ix { int x; };`.

On the other hand, if the homework assignment is about OOP principles, then knock yourself out with whatever definition your lecturer has given you of "object". Since I don't know what that is, I can't tell you what answer he'll consider correct...

Problem

Given this: ``` struct { int x; } ix; struct A { A() {}; int x; }; A ia; ``` Which of these is true? ``` a. ix is an object b. ia is an object c. both are objects d. both are not objects. ```

Original source