Define object, classes and instances.

Define object, classes and instances.

Object :
Object is the basic run time entity in an Object Oriented (OO) System. From a programmer’s perspective, it is a storage region with associated semantics. From a designer’s perspective, it is an identifiable component in the problem domain. Object is essentially a variable of user defined data type class.

Class :
User defined data type which contains data and methods to manipulate that data; is known as class. It is the fundamental packaging unit of OO technology. An object is a variable of a Class. Each object is associated with the data of type class with which it is created. Thus we can also say that class is a collection of objects of similar types. It is a user defined data type and behaves like built-in data type of the language.

Instance :
Object can also be called as runtime instance of a class. It is used to access data and function members while a program is running. As stated earlier, class specification provides only a template. It does not create any memory space for the object. To create memory space at runtime, we need to create instance of the class, which is essentially the class object.

Consider the following example :
Class Student   --- Class Definition
{
   int rollno;
   int marks;
   public:
       void show(int roll)
       {
          cout<< rollno: << marks;
       }
};

void main()
{
   Student s;    --Object of Class
   s.show();
}
- Here, Student is a user defined data type - Class
- In main(), variable of this user defined data type Student is created, which is the object of that Class.
- This object of class is also known as instance.
What is multiple inheritance? - C++
What is multiple inheritance? - When a class is derived from another class ie it inherits functionalities of another class, this phenomenon is known as inheritance....
What are the syntax and semantics for a function template? - C++
Function template - Templates is one of the features of C++. Using templates, C++ provides a support for generic programming....
Differentiate between a template class and class template - C++
Differentiate between a template class and class template - Template class: A class that has generic definition or a class with parameters which is not instantiated until the information is provided by the client...
Post your comment