




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Niraj Yadav 1/14/18 OOP
Object Oriented Programming Object-oriented programming (OOP) is the most recent concept in computer programming approach. OOP allows decomposition of program into a number of entities called objects and then builds data and functions around these objects. However, the function of one object can access the functions of another object. As the OOP is the modern programming language it has some principal and characteristics which are discussed below: Class Object is the basic element of OOP approach which is declared by using class. Class is a collection of objects of similar type. For example, mango, apple and orange are the members of the class fruits. Classes are user defined data types and behave like the built in data types of the programming languages. Classes are also known as abstract data types (ADT) in OOP because they use the concept of data abstraction. Objects Object is the basic run time entities in an object oriented program which consists of data and functions. It may also represent user defined data. Programming problem is analyzed in terms of objects. The program objects are similar to the real world objects. Hence, object is a variable consisting both routine and data that is treated as discrete entity within programming. Data Abstraction Data Abstraction is the lessening of a specific assortment of information to a rearranged representation of the entirety. Abstraction, by and large, is the procedure of taking without end or expelling qualities from something keeping in mind the end goal to diminish it to an arrangement of crucial attributes.
Encapsulation Encapsulation is striking part features of OOP approach. The wrapping up of data and function into a single unit called class is known as encapsulation. The data is not accessible to the outside world and only those functions which are wrapped in the class can access the data. This feature of OOP approach prevents the data from the accidental or unnecessary modifications. The functions of the object provide the interface between the object data and program. The code that defines encapsulation is shown below:
Constructer A "constructor" is an extraordinary part work whose endeavor is to actually present of an object of its class. It is excellent in light of the fact that its name is the same name of the same as the class name. It is called constructor since it fabricates the assessed estimations of the information individuals from the class. Rules to write constructer are given below:
Destructor "Destructor" capacities are the opposite of constructor capacities. They are called when articles are crushed (deallocated). Assign a function as a class' destructor by going before the class name with a tilde (~).Rules to write destructor functions are:
Types of Inheritance Single Inheritance Single Inheritance a typical type of inheritance, in which classes have one base class. The base class from which every class is inferred is pronounced before the presentation of the determined class. It is not adequate to give a forward-referencing statement to a base class; it must be a finished revelation. The program and Output is given below: