Skip to main content
Engineering LibreTexts

1.3: OOP Objects

  • Page ID
    34635
  • An Object is an identifiable entity with some characteristics and behavior. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated.

    class person 
    { 
       char name[20]; 
       int id; 
       public: 
          void getdetails(){} 
    };
    
    int main() 
    { 
       person p1; // p1 is a object 
    } 

    Object take up space in memory and have an associated address just like any other date type in C++.

    When a program is executed the objects interact by sending messages to one another.

    Each object contains data and code to manipulate the data. Objects can interact without having to know details of each other’s data or code, it is sufficient to know the type of message accepted and type of response returned by the objects.

    Adapted from
    "Object Oriented Programming in C++" by Vankayala Karunakar., Geeks for Geeks is licensed under CC BY 4.0