Oriental University Indore A Smart University Sanwer Road

  • Slides: 17
Download presentation
Oriental University, Indore A Smart University Sanwer Road, Jakhya, Opposite Revati Range , Gate

Oriental University, Indore A Smart University Sanwer Road, Jakhya, Opposite Revati Range , Gate No. 1, Indore (M. P) - 453555

Computer Science & Engineering Department B. Tech III Semester Object Oriented Programming with C++

Computer Science & Engineering Department B. Tech III Semester Object Oriented Programming with C++ Subject Code: BTCS - 304 Dr. Tanmay Kasbe UNIT - I Ph. D (Computer Science) HOD & Associate Professor Computer Science & Engineering Oriental University, Indore tanmay. k@orientaluniversity. in

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Introduction of Object Oriented Programming An object oriented programming language is a High level programming language which is giving more emphasis on Object & Data rather than only on function and procedure. In object oriented programming language developer not only to define data types of data structure, but also the type of operation by the help of function on that data structure. In object oriented programming language each object is independent to each other & they can communicate to each other by the help of functions. Not all the programming language suits the OOPL paradigm but most of the modern programming language follow concepts of object oriented programming language. The first OOPL language was Simula, developed in 1960 s. Smalttalk is considered to be first true object oriented programming language, developed in 1972. On modern programming language JAVA , . NET , Python , Ruby are the most popular programming language. Object-oriented programming makes it easier for developers to structure and organize software programs effectively 3 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Some of the important features of OOP languages are : üMain emphasis on Data & Objects. üLarge program divide into smaller parts known as an Object. üData is fully secure & cannot be used by external functions. üObjects are communicated with each other by the help of functions. üObjects are not depends upon each other. üWe can easily manage memory management. üFairly suitable for large software projects. üOOP follow bottom-Up approach. 4 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Introduction to Procedure oriented programming The Procedure oriented programming language is giving more emphasis on functions. In procedure oriented programming language problem is seen as a sequence of things. If you want a computer to do something, you should provide step-by-step instructions on how to do it. It is, therefore, no surprise that most of the early programming languages are all procedural. Examples of procedural languages include FORTRAN, COBOL and C, which have been around since the 1960 s and 70 s. In procedure oriented programming there is no security for data & data can move freely in different functions. One major problem with POP is that it is not emphasis on real word problem. It contains a systematic order of statements, functions and commands to complete a computational task or program. Procedural language is also known as imperative language. One of the biggest problems in Procedural Programming is that if a edit is needed to the program, the developer must edit every line of code that corresponds to the original change in the code. An example would be if at the beginning of a program a variable was set to equal the value of 10. If other sub-functions of the program depend on that variable equal to 10 to function properly they will also need to be edited. As more and more changes may be needed to the code, it becomes increasingly difficult to locate and edit all related elements in the program. 5 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Some of the features of Procedure-Oriented Programming Language are – üData is not secure in POP. üMain emphasis on sequence of things. üData can easily move from one function to other functions. üLarge program divide into smaller parts know is functions. üSince every function has complete access to the global variables, the new programmer can corrupt / view the data accidentally by creating function. üPOP follows Top Down approach. 6 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Object Oriented Programming Concept All concepts are important concept and each concept has its own special characteristics. Most of the OOP language must follow all or some of the concepts. Following are the main concepts of OOPs – üObjects üClass üPolymorphism üInheritance üData Abstraction üData Encapsulation üMessage Passing 7 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Objects In programming terms, an object is a self-contained component that contains properties and methods (also known as functions) needed to make a certain type of data useful. An object’s properties are what it knows and its methods are what it can do. Objects may represent a student, a chair, a wall clock or any item that is used by program. We can create any number of objects in a program & every object is independent to each other. When a program is executed then objects communicate to each other by sending the messages. For Example, If faculties assign some project to the students then the project management application had a status object, a cost object, and a client objects. 8 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Classes A class is a collection of same type of objects. When you define a class then you can declare any number of objects. Class is also called a user define data type. Each class is designed to have only a single responsibility; many classes are used to build an entire application. For example: Cricket, Hockey, Football are member of Sports class. T 20 , ODI , Test are the Cricket class Class. Name , Student. Name, College. Name are member of University class. 9 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Polymorphism means one form many interfaces. It is one of the important concepts of OOPs. Polymorphism means to process objects differently based on their data type. In other words it means one method with multiple implementations, for a certain class of action. Real Life Example: A Mobile phone is one medium but we can use mobile for different purpose like messaging, Whatsapp, Games, Watching videos etc…… A Glass is single interface but we can use glass as drink water, drink a soft drink, and drink a hard drink… In old programming language like C, Pascal we not use same name of function more than one time. But in OOPL we can use same name of function more than one time but its implementation is different. 10 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Types of Polymorphism 11 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Inheritance is specific to object-oriented programming, where a new class is created from an existing class OR we can say that the reusability of code is called Inheritance is a feature that represents the "is a" relationship between different class. In programming there are several situations where we required using common method or functions like when we talk about students of particular college then there are common attributes like College Name, College Address, Affiliation, and Timing. So in the concept of inheritance we can declare the entire common attribute in a class is called base class or parent class. In other class we can say subclass or derived class in which we have define different attribute like student name , class, Stream. In object-oriented programming language inheritance provides us a facility where object of one class can be used the properties or code of other class. 12 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Inheritance 13 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Data Abstraction is a process where you show only “relevant” data and “hide” unnecessary details of an object from the user. Abstraction is the process of recognizing and focusing on important characteristics of an object and leaving/filtering out the un-wanted characteristics of that object. Abstraction provides you a generalized view of your classes or object by providing relevant information. Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner. For Example: Let's take one real life example of a TV, which you can turn on and off, change the channel, adjust the volume, and add external components like speakers, BUT you do not know its internal details, that is, you do not know how it receives signals, how it translates them, and finally displays them on the screen. So this is a called a abstractions Car Brakes, Bike Brakes- You just knows that pressing the pedals will stop the vehicle but you don’t need to know how it works internally. 14 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Data Encapsulation is the process of binding (combining) data and functions into a single unit called class. In Encapsulation, the data is not accessed directly; it is accessed through the functions present inside the class. Encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object. It is mechanism, by which we protect our data from outside. Example of a power steering mechanism of a car. Power steering of a car is a difficult system, which internally have lots of components tightly coupled together, they work parallel to turn the car in the desired direction. 15 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Difference between Abstraction and Encapsulation Abstraction solves the problem in the design level. Encapsulation solves implementation level. the problem in the Abstraction is used for hiding the unwanted data and giving relevant data. Encapsulation means hiding the code and data into a single unit to protect the data from outside world. Abstraction lets you focus on what the object does instead of how it does it Encapsulation means hiding the internal details or mechanics of how an object does something. For Example: Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number. For Example: Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits. 16 @ Dr. Tanmay Kasbe

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT -

B. Tech III Semester BTCS- 304 : Object Oriented Programming with C++ UNIT - I Advantages of OOP üIt presents a simple, clear and easy to maintain structure. üFaster development of software and lower cost of development allows more time and resources to be used in the verification of the software. üThe principle of data hiding helps the programmers to built secure program that can’t be invaded by code in other parts of the program. üIt is easy to partition the work in a project based on objects. üIt is easy to maintain and modify existing code as new objects can be created with small differences to existing ones. üIt implements real life scenario. üIn OOP, programmer not only defines data types but also deals with operations applied for data structures. 17 @ Dr. Tanmay Kasbe