I will just offer a slightly different perspective, but nothing that hasnât been said already.
A class in object-oriented languages, is this abstract notion of how the object is supposed to work. Like a blueprint.
An object instance, on the other hand, is when you do actually make an object from this blueprint. You can have just one (thatâs known as a singleton) or many such instances.
All objects from the same class share the classâs code, but have separate data for the fields and properties as specified by the class. What is unique about them is what takes up the memory. Thus you never copy the unchanging stuff.
However, even a class itself is an object, and can be referred to, however if you manage to do that, thatâs âbehind the scenesâ access known as reflection. Normally programs only refer to fields, properties, and methods which can return either references to some instances or simple, primitive data (numbers, textâŚ).
Some of the fields, properties, and methods can be also static, which means that they do not need an instance to live on, but live in the class definition instead.
For the compiler to know what a variable will hold, it needs to be declared for a certain type. All classes are types.
When you say PeanutButter instancegjhgf
PeanutButter is the type and likely some class, while instancegjhgf is the name youâve chosen for the actual handler of this reference (aka identifier).
All variables must have a valid type and a valid identifier. But the type can also be primitive. For example a typical decimal number is usually represented with a keyword float
. This is also known as a primitive type alias. The actual class of that type is in fact called System.Single. Same goes for int
. It is in fact System.Int32.
Primitive types normally hold primitive values, and are called value types because of this, their values are copied around when passing. But object instances arenât copied like this, because they tend to get big in memory, and are passed âby referenceâ instead.
Therefore,
DCDestinationMarker DreamDestination;
is a declaration of a variable, with an identifier named DreamDestination, the whole thing is either a field in another class, or a variable that is local to some method, holding a reference type for any of the instances of a class called DCDestinationMarker. Further, in the top of the file, you can find its âusingâ declaration listed, and figure where this class comes from.