You are here:

C++/object and instance?

Advertisement


Question
Hi,
when should we user the word "object", and when the word "instance"?

Thanks,
lzzzz

Answer
Dear lzzzz !

 The term object means a combination of data and logic that represent some real world entity ,
  eg:
     Consider BMW cars . The BMW can be represented  in a computer program as an 'object' , in which the data part of the BMW object is the car's name  , color , price  , and so on.

  Class defnition differentiate one object from other but in fact a class is a set of objects that share a commnon structure and common behaviour , a signle object is simply an instance of a class.

   A real-world example of an object would be "BMW-M5", which is an instance of a type (a class) called "BMW", which is a subclass of a class "CARS".
   
   In the case of a polymorphic object, some details of its type can be selectively ignored,
     for example a "BMW" object could be used by a function looking for an "CARS". So could a "LIMO", because it too belongs to the class of "CARS".
     While being accessed as an "CARS", some member attributes of a "BMW-M5" or "LIMO" would remain unavailable, such as the "ROOF" attribute, because some cars may not have roof !


Regards !
Prince M. Premnath

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.