You are here:

C++/object and instance?


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


Dear lzzzz !

 The term object means a combination of data and logic that represent some real world entity ,
     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


All Answers

Answers by Expert:

Ask Experts


Prince M. Premnath


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


More than 5 years


©2017 All rights reserved.

[an error occurred while processing this directive]