I have a wording / precision question. Sometimes I write "object instance" sometimes "class instance".

Isn't it that an object is always an instance of a class? Therefore "object instance" is not the correct wording, right?

Is it common to say so anyway, or just a "mistake" of mine? I have the feeling "object instance" is superfluous (doubled) because an object is always an instance and would like to know more for clarification of the terms.


No, it is not right that an "object" is always an instance of a class. Just for example, the standard for C (which doesn't have classes at all) defines an object as (§3.14/1): "region of data storage in the execution environment, the contents of which can represent values."

Now, it is true that using "object" to refer to an instance of a class is quite common. In some languages (e.g., Smalltalk) all objects are instances of classes. In others (e.g., C++) the term is somewhat ambiguous, because there is a C-like use of the term and a Smalltalk-like use of the term, so it's not necessarily clear whether "object" is being used to refer specifically to an instance of a class, or just to some region of data storage in the execution environment, which may be an instance of some primitive type rather than a class, or may be (for example) some dynamic storage that hasn't been initialized, so it's not really an instance of any type.

As far as "object instance" making sense, I can see one situation where it could. Going back to Smalltalk: everything in Smalltalk is an instance of a class -- even a class is an instance of a class (called the metaclass). In a case like this, I can see where it could (sort of) make sense to talk about an "object instance", when you were specifically talking about an instance of a class as opposed to the class of the class.

In fairness, however, that usage is undoubtedly quite rare (at most). The vast majority of the time, "object instance" is probably just sloppy wording.

  • 1
    +1 That clarifies a lot for the terms meaning, thanks a lot. – hakre Aug 7 '11 at 16:00
  • 3
    Somewhere in Ch. 10 of The C++ Programming Language, Stroustrup talks about the distinction between object as region of memory and object as instance of a class, and cautions that they shouldn't be confused. It seems clear to me that the "region of data storage" definition isn't the one intended by this question. – Caleb Aug 7 '11 at 19:52
  • 1
    @Caleb: Now this is getting really great, that's mirroring my feelings. Thanks for your comment. – hakre Aug 7 '11 at 21:18

An object, often called an instance, is a specific instantiation of a class. If you instantiate (make an instance of) a class ten times, you get ten objects, but there's still just the one class.


The term object can refer to (at least) three different independent concepts:

  1. An instance of a class. This is the case for object-oriented, strongly-typed, statically-typed languages such as Java and C#. In these languages, the "class" is the definition and "object" is a single manifestation ("instance") of that.

  2. An untyped area in memory containing functions and data/state. This is what you'll find in many dynamically-typed but still object-oriented languages, especially scripting languages such as JavaScript. In this case, there is no "class", and there is no "instance" either, there are just objects, period.

  3. Any addressable memory or data in a program. This was the commonly-accepted definition before OOP existed, and is still part of the C spec, as Jerry Coffin explains.

So this is essentially a two-part question, the answers being:

  • The term "object" is always correct in object-oriented languages. The term "class instance" is sometimes a synonym, but that depends on the specific language.

  • The term "object instance" is never correct. In languages that define objects, but not classes, the term "instance" is meaningless because every object is by definition an instance of something.

If you want to be safe, just avoid using the term "instance" unless you specifically need to distinguish between the type definition (class) and an instance of that type, e.g. when referring to an instance member vs. a class or static member.

  • +1 Very nice structured differentiation for the term object. – hakre Aug 7 '11 at 16:32
  • I object to #1. An object is an instance of a class even in some dynamically typed languages - and I suspect in some weakly typed ones, too. I also object to #3. "Object" was a common definition for a piece of addressable storage in at least one OO language for at least a decade before Java was even invented. – sbi Aug 7 '11 at 19:04
  • @sbi: I said "this is the case for X languages", not "this is not the case for any other languages". As for #3: Which one? You'd better not say "smalltalk", because that would be wrong. – Aaronaught Aug 7 '11 at 19:14
  • #3 is part of the C++ spec too, and as such, isn't really "pre-OOP". It's also not "any addressable memory", but "any data type stored in memory". A C++ (or C, afaik) object does not exist until you actually write a value to memory. So honestly, I don't really see it being that incompatible with "the OOP meaning". – jalf Aug 7 '11 at 20:33
  • @jalf: If we're going to nit-pick, the C++ specification contains the literal text, An object is a region of storage. However, the C++ specification almost always delineates the type of object, e.g. "class object" or "struct object". It also frequently makes distinctions between values and objects and refers to "instances of X" (X being class, struct, the name of a specific type, etc.) So "class instance" and "object" are essentially synonyms in the C++ spec as well, except the "object" can refer to other things too. – Aaronaught Aug 7 '11 at 22:34

The class is the compile-time specification of the object. The object is the runtime realisation of that specification.

Therefore when you create an object you are creating an "instance of a class", or "class instance".

  • @Aaronaught Yeah - on reflection it was a bad call. I'll edit accordingly. Other better answers will doubtless float up. – Gary Rowe Aug 7 '11 at 16:07

An object instance would be something which corresponds to that object in the same way that a class instance corresponds to a class. I am not aware of any mainstream concepts that match that definition...

Also, while it's true that a class instance is always an object, objects are not always class instances : some languages support the creation of objects as literals. Consider, for instance, the JavaScript object defined as:

var bob = { name : "Bob", age : 31, birthday : function() { this.age++ } } ;

Or the OCaml equivalent:

let bob = object
  val name = "Bob"
  val age  = 31
  method birthday = {< age <- age + 1 >}
  • 1
    This is a good point; not every object-oriented language is also statically or even strongly-typed, so the word "object" is literally just a generic object. I still wouldn't use the term "object instance" though - that seems to be wrong in any language. – Aaronaught Aug 7 '11 at 16:15

Isn't it that an object is always an instance of a class? Therefore "object instance" is not the correct wording, right?

int i;

Disproof by counter-example.

On the other hand, "object instance" is not good, and nor is "class instance", because not every object is an instance of a class. I'd usually just say "instance" or "object".

  • 2
    ^ Except in languages where it isn't an object, like just about every language that uses primitives instead of classes for integers. Its a primitive, not an object. -1. – alternative Aug 7 '11 at 15:25
  • 3
    i is not an object, it's a variable, and whatever gets assigned to it is its value. A value can be an object, but isn't necessarily one. This is where the distinction between value and reference types comes in. Reference type instances (i.e. class instances) are objects. Value type instances are simply values, and they behave very differently from reference type instances (objects). – Aaronaught Aug 7 '11 at 15:49
  • 2
    Yeah ok, if you're going to use that defense then you have to be a little more specific with your counter-example. You just wrote "int i" and didn't specify the language; in most languages that use that syntax (Java, C#, C++, D, etc.) "class instance" is exactly what "object" means. The only exception is C, and C doesn't have "classes" at all, so that doesn't appear to be the basis for your answer. – Aaronaught Aug 7 '11 at 16:06
  • 3
    Look, you've given us a "disproof by counter-example" that (a) doesn't disprove anything and (b) isn't even a real example. You can't just invent your own definitions and justify it on the basis that the OP didn't specify a language. If you can find a real counterexample (as Jerry Coffin did and as I explicitly alluded to in my "I should qualify my comment" follow-up), great. Otherwise, you're not adding anything constructive – Aaronaught Aug 7 '11 at 16:12
  • 3
    @sbi: No, DeadMG hasn't shown any actual language. There is no language specified or even clearly implied, and the OP has refused to clarify. I'm fairly certain that the downvotes are for the utter lack of substance in this answer, and not necessarily because the vague point it's attempting to get across is actually wrong. You also don't know how or if I voted, and you have no business telling me or anybody else how to vote. – Aaronaught Aug 7 '11 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.