Arbalest
Arbalest

Reputation: 1105

Please clarify the term Class Static Object (vs class static member)

I've run across the term Class Static Object a number of times without code or context to clarify if this is the author's term for something I don't know or an just another term for class (scoped) static member (variable or function).

class m1 {
public:
    static int x;
};

// with x being the "class static "object"
// which I just call a "class static member".
int m1::x;

Or, does the term only apply to member variables that are actually user defined objects?

class m2 {
public:
    int y;
};

class m3 {
public:
    static m2 z;
};

// with z really being an object - the "class static object"?
m2 m3::z;

Upvotes: 0

Views: 69

Answers (1)

Jesse Good
Jesse Good

Reputation: 52365

I would consider both cases to be referring to "Class Static Objects". An object is simply an entity which occupies memory that is not a function, so it does not matter whether it is a user-defined type (UDT) or not.

As for the difference between "class static member", functions can also be "members", so I would say the difference is that "Class Static Object" does not include functions.

Personally, I would use "static member variables" and "static member functions", rather than that terminology.

Upvotes: 1

Related Questions