c++ basic terminology clarification

been using jumping into c++. i felt like i understood the words but was quite confused by the way and context word was used in some places. appreciate it if you could clarify the meanings of these basic words:

1. reading a varible
2. instances
3. objects
4. elements

1. Reading a variable, is accessing its value, without modifying it, for example:
1
2
int x (10);
std::cout<<x<<std::endl;

This first initialises and then reads x.

2. An instance can be one of two things:
An instance of a class, is just an object of that class.
An instance variable, is a non-static member variable.

3. An object is a variable, but usually of a non-primitive class (such as a user-defined class).

4. Elements are variables in an container (array/vector etc).
I am going to try to put this into simplest terms for you because I remember when I was in your position so here it goes.

1) A variable stores data so when you read a variable you are looking at the contents of that variable.

2) An instance is referred to a specific object that was created with a class.

3) An object is a more complex variable. With a simple variable such as an int, string, or char they can only hold once piece of information.
An object variable can store many different types of variables and other information such as functions.
Think of an object such as a person. This variable person which is an instance of the Person class, can hold data such as a name and age.
When you create a class you describe the type of data that the object will hold. When you create an instance of that class you create the actual data.


int age = 20;
string name = "yourname";
Person person (name, age);

4) Elements are data that is stored in container datatype such as an Array.
Last edited on
thnx guys. much better confidence in these terms. still, are instances and objects same/similar?
Lets Say Nike wants to make an new shoe line. Nike Air-force 2:FlashBack series.
Lets Say Nike's marking department (I am not sure if this is what marketing people do) decides that the new Nike Air-force 2:FlashBack series, will have a new shoe realeased every month for two years.


THE OBJECT:
So Nike creates a Base Shoe: (A shoe that has ALL the common designs properties / patterns that each new Nike Air-force 2:FlashBack series shoe will share ) as these properties are what defines the basic design of the Nike Air-force 2:FlashBack series.

THE INSTANCE:
So each month Nike's design team takes the base shoe and creates a new style "Nike Air-force 2:FlashBack series." from the BASE shoe while tweaking all and changing all the common design patterns and features from the base shoe. Like color / height / or anything else that was included as property or variable of the base shoe model.

Last edited on
so a general variable of a class type is an object and each object with unique values of member fileds of that class is an instance, is it? hope that wasn't vague.
thnx and btw cool name though: "Nike Air-force 2:FlashBack series". i could probably earn some money selling that name to Nike. ha.
Topic archived. No new replies allowed.