关于对象的哪些陈述是真的?

Mur*_*ali 6 c++ object

鉴于这种:

struct { int x; } ix;

struct A { A() {}; int x; };
A ia;
Run Code Online (Sandbox Code Playgroud)

以下哪一项是正确的?

a. ix is an object
b. ia is an object
c. both are objects
d. both are not objects.
Run Code Online (Sandbox Code Playgroud)

Ste*_*sop 10

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