Basic of OOPs(Object Oriented Programmings)

 Definition:-
                   OOP (Object Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts.


CLASS:-

  • It is defined data type which defines its properties and its functions.
  • It is the only logical representation of data.
  • It is blue print of objects.
  • For example:- Human beings is a class. The body part are its properties, and the actions performs by human is its function.
  • Class does not occupy any space till an object is instantiated.
  • Class is define by using keyword class followed by the name of class.

Here, we defined a class named Room.
The Variables length, breadth and height are declared inside the class are known as data members. The functions calculateArea() and calculateVolume() are known as member functions of a class.

OBJECT:-
  • It is run-time entity.
  • It is an instance of the class.
  • An objects can operate on both data members and member functions.


Here, two objects room1 and room2 of the room class are created in sampleFunction(). similarly the objects room3 and room4 are created in Main().
We can create objects of a class in any functions of the program. we can also create objects of a class within the class itself or in other classes.


Note:- When an objects is created using a new keyword, then space is allocated for the variable in a heap, and the starting address is stored in the stack memory. When an object is created without a new keyword then space is not allocated in the heap memory, and the object contain the null value in the stack.



               

           

Comments

Popular posts from this blog

Tips to improve Coding Skill