Object is a component of the program which knows how to carry out
some actions and interact with other pieces of a code.
A D V E R T I S E M E N T
previously have been described as the "black boxes" takes the input and spit out the output.
An objects can be thought as a "smart" black boxes. which know how to do
more than one specific action, and also they can store own set of data. Designing the
program with an object allows the programmer to model a program after a real world.
Here is a "Player" object. This object have attributes healthh, strength and ability.
These attributes in terms of Programming language are called as data members.
The various actions that a player oject can perform are move, attakMonster and getTreasure,
These actions are called memeber Functions.
Objects and the Instances
There is a distinction between object and the instance of an object.
Object is the definition or a template for its instances. And
instance is the actual thing which can be manipulated. For example we have one
instance of the player object with certain values:
Player Instance #1:
health = 16
strength = 12
ability = 14
Here is one instace of the object "Player" with the values for health, strength and
ability as 16, 12 and 14 respectively.