Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class
|
|
- Daniel Wade
- 5 years ago
- Views:
Transcription
1 Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel Inheritance; Nesting of Class;
2 Introduction of Inheritance The capability of one class to inherit properties from another class; The most important advantage of inheritance is code reusability. Once a base class is written and debugged; it can be used in various situation without having to redefine it. Already tested and saved previous code an be reused. Reusing existing code saves time, money and efforts and increase a program reliability.
3 Need for Inheritance Inheritance is very powerful concept of OOP. There are several reasons for inheritance was introduced in OOP. They are as follows One major reason behind this is the capability to express the inheritance relationship, which ensure the closeness of real world model; Another reasons is the idea of reusability. One reason is transitive nature of inheritance.
4 Advantage of Reusability The advantages of reusability are fastest development time, easier maintenance and easy to extend. Inheritance allows the addition of additional features to an existing class without modifying it. One can derive a new class from existing one and add new features to it.
5 Different form of Inheritance There are many forms of Inheritance; which are as follows. Single Inheritance; Multilevel Inheritance; Multiple Inheritance; Hierarchical Inheritance; Hybrid Inheritance;
6 Single Inheritance When a subclass inherits only from one base class; It is known as Single Inheritance A Base Class B Derived Class
7 Multilevel Inheritance The transitive nature of Inheritance is reflected by this form of inheritance. When a sub class is inherits from a class that itself inherits from another class; It is known as Multilevel Inheritance. A B C Base Class of B Sub Class of A & Base Class of C Sub Class of B
8 Multiple Inheritance When a sub class inherits from multiple base classes, it is known as multiple inheritance. In other words, when more than one classes together generate another class. The such type of inheritance is called multiple Inheritance. Base Class of B Base Class of A B A C Sub Class
9 Hierarchical Inheritance When many sub classes inherit from a single base class, it is known as hierarchical inheritance. A Base Class B C D Sub Class of B Sub Class of C Sub Class D
10 Hybrid Inheritance Hybrid inheritance combines two or more forms of inheritance e.g., When a sub class inherits from ultiple base classes and all of its base classes inherit from a single base class, this form of inheritance is known as hybrid inheritance. A A B C B C D D E F
11 Derived And Base Classes A Derived / Sub / Child class is defined by specifying its relationship with the Base / Super / Parent Class in addition to own details. Syntax to defining the derived class class derived : visibility mode base_class_name The visibility mode controls the visibility and availability of inherited base class members in the derived class.
12 Ex class Sub : public Super // public derivation... // Class Members class Sub : private Super // private derivation... // Class Members class Sub : protected Super // protected derivation... // Class Members class Sub : Super // by default private derivation... // Class Members
13 Extra Notation Actually a derived class inherits all the members of a base class; however the derived class has access privilege only to the non private members of the base class.
14 Declaration of Multiple Inheritance A class inheriting from multiple base classes is known as multiple inheritance. The syntax as class derived : vs_mode base1, vs_mode base2, Ex.. class sub : public base1, private base2.
15 Visibility Mode Visibility modes Inheritable public members becomes in derived class Inheritable protected members becomes in derived class Public Public Protected Protected Protected Protected Private Private Private
16 The Public Visibility Mode The public derivation means that the derived class can access the protected and public members of base class, but not the private members of the base class. In this type of derivation public members of base class becomes public and protected members becomes protected of derived class.
17 Private Visibility Mode The private derivation means that the derived class can access the public and protected members of the base class. These members becomes private of derived class. Private members can access only the public member functions.
18 Protected Visibility mode The Protected derivation means the public and protected members of the base class becomes the protected members of the derived class.
19 Extra Notations While deriving a base class, following things should be kept in mind. Members should be intended and at the same time intended to be available to every function, even to non member function. Member intended to be inherited but not intended to be public, should be declared as public. Members not intended to be inherited should be declared as private.
20 Accessibility of Base class Members Access Specifier Accessible from own class Accessible from Derived Class (Inheritance ) Public Yes Yes Yes Protected Yes Yes No. Private Yes No. No. Accessible from object Outside the class
21 Constructor & Destructor in Inhritance When an object of derived class is created, the program first call the constructor of the base class and then constructor of the derived class. This is the same way as the first floor of a building is constructed before the constructing of the second floors. While defining the constructor of the derived class it should be kept in mind the work of constructor may not be duplicate. Similarly, when an object expire, the program should be call derived class destructor and then call base class destructor. It is also same way we first destroy the second floors of the building, before destroying the first floors.
22 EX Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat class super Destructor super() cout<< Call First ; } Constructor class sub : public super sub() cout<< Call Next ; } class super ~super() cout<< Call Next ; } class sub : public super ~sub() cout<< Call First ; }
23 EX Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat #include<iostream.h> #include<conio.h> class base base() cout<<endl<<"base \n"; } class derive:public base derive() cout<<endl<<"derive \n"; } void main() clrscr(); derive d; derive k; getch(); } Base OUTPUT Derive Base Derive
24 Derived Class Parameterized Constructor Some times base class constructor require arguments to construct their object. In such case it is the responsibility of the derived class constructor to pass those argument required by corresponding base class. To Pass these base class argument, the constructor of the class uses a special mechanism. derived(type1 x, type2 y) :base (x, y).. } The colon in the derived class constructor function means pass the derived argument to base class constructor.
25 EX Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat #include<iostream.h> #include<conio.h> class base int a; base(int x) a=x; cout<<endl<<"base "<<a; } class derived:public base int b; derived(int x,int y):base(x) b=y; cout<<endl<<"derived "<<b; } void main() clrscr(); derived d(25,30); derived k(40,50); getch(); } OUTPUT Base 25 Derive 30 Base 40 Derive 50
26 Access Control in Publicly Derived class A class is publicly derived when the keyword public precedes the base class name in the class definition as given below. class derived : public base.. By this type of inheritance Public member of base class becomes public in derived class. Protected member of base class becomes protected in derived class. Private Members of base is not accessible in derived class
27 Access Control in Privately Derived class A class is privately derived when the keyword private precedes the base class name in the class definition as given below. class derived : private base.. By this type of inheritance Public member of base class becomes private in derived class. Protected member of base class becomes private in derived class. Private Members of base is not accessible in derived class
28 Access Control in Protected Derived class A class is protected derived when the keyword protected precedes the base class name in the class definition as given below. class derived : protected base.. By this type of inheritance Public member of base class becomes protected in derived class. Protected member of base class becomes protected in derived class. Private Members of base is not accessible in derived class
29 Facts about Inheritance Private members of base class are not directly accessible in the base class, but that does not affect its visibility in the derived class. The private members of base class are still visible in derived class. int test; // global var. int test1;// global var. class base int test; void getit(int x) cout<<endl<<"enter value "; cin>>test; } class derived :public base void check() test++;//not allowed bcoz private member; // global test is hidden also ::test++//global var. test1++;//global var direct access. }
30 Making a Private member Inheritable In Inheritance, only public and protected members of the base class is inheritable into the derived class. But we want to private members inheritable. Any derived class get not privileges to access private members of the base class directly. But this can be possible into two ways. By Making visibility mode of private as public. By Making visibility mode of private as protected.
31 Not Inheritable Class Der1:Public Base Private Protected Public Private Protected Public Class Base Class Der2:Private Base Private Protected Public Class Z:Public Der1,Private Der2 Private Protected Public
32 Multiple Inheritance Multiple inheritance means deriving a class from more than one base class. With multiple inheritance, the new classes inherits all the public and protected members of the base classes. class x int a; void fx1(); protected: char b; void fx2(); float c; void fx3(); class y int d; void fy1(); protected: char e; void fy2(); float f; void fy3(); class z : public x, public y int g; protected: int h; void display();
33 Constructor in Multiple Inheritance The constructor play an important role in initializing the object. One important is that, no base class constructor takes argument, then derived class is not need to define constructors. But if base class constructor is needs arguments then derived class constructor is needed and passes argument to base class constructors. Constructor can not be inherited. derived (int a,int b):base1(a),base2(b),... }
34
35 Virtual Base Class An element of ambiguity can be introduced into C++ program when multiple base classes are inherited. class base int a; class D1 : public base int b; class D2 : public base int c; class D3 : public D1, public D2 int total; void main() D3 ob; ob.a=25; ob.b=30; ob.c=40; ob.total=ob.a + ob.b + ob.c; // a is ambiguous; cout<<ob.a<<ob.b<<ob.c<<ob.total; } D1 Base D3 D2
36 Explanation Both D1 and D2 inherit base, they both have copies of base. However D3 inherit from D1 and D2. This means that there are two copies of base present in the object of D3. ob.a = 25; // this is ambiguous; Here a is of which class? Either D1 or D2 There are two way to overcome this situation. The first is apply is the scope resolution operator The second way is - virtual base class.
37 Solution by :: operator void main() D3 ob; ob.d1::a=25; ob.b=30; ob.c=40; ob.total=ob.d1::a + ob.b + ob.c; // a is ambiguous; cout<<ob.a<<ob.b<<ob.c< <ob.total; }
38 Solution by Virtual Base classes Base When two or more virtual D1 vittual D2 object are derived from a common base class, you can prevent multiple copies of the base class from being present in an D3 object derived from those objects by declaring the base class as virtual, when it is inherited. This is accomplished by putting the keyword virtual before the base class name, when it is inherited.
39 Ex class base int a; class D1 : virtual public base int b; class D2 : virtual public base int c; class D3 : public D1, public D2 int total; void main() D3 ob; ob.a=25; ob.b=30; ob.c=40; ob.total=ob.a + ob.b + ob.c; // a is ambiguous; cout<<ob.a<<ob.b<<ob.c<<ob.total; }
40 Multilevel Inheritance Some times a derived class itself, acts as base class for another class. Such a situation is called multilevel inheritance. The chain of classes forming multilevel inheritance is known as inheritance hierarchy or Inheritance path. The multilevel inheritance implements the transitive nature of real life objects. There can any number of classes in the inheritance hierarchy
41 Nesting of Class When a class contains objects of other class types as its members, it is referred as Containership or Containment or Aggregation. class X... class Y class Z X obj1 ; Y obj2;. All the object of Class Z will be containing object Ob1 and Ob2 of X and Y types respectively. This type of relationship is called containership or nesting. It is also referred as Containment, Composition or Aggregation This can also say that Class Z has HAS A relationship with Class X and Class Y.
42 Ex Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat class subject Initialize the int num; float max-marks; subject (int n, float m) object and call num = n; max-marks=m; } the constructor class student int rollno; subject sub; Student (int r, int n, int m) : sub (n, m) rollno=r; }..
43 Extra Notations The Constructor for a member object of a class is invoked implicitly (through the name of constructor) And the constructor for the base class is invoked explicitly (through the class name)
44 Relationship Between Classes, HAS-A When a class is inherit from another class, is known as IS- A relationship. And when a class contains the object of other class type as member is known as HAS-A relationship. The class having HAS-A relationship with other class has Ownership of the container object. Ownership defines the creation and destruction of an object. It means if Container class object creates then other class also create with it, similarly Container object is destroy, then inner object simultaneously destroy
45 It is same as HAS- A relationship, but ownership is missing in HOLD- A relationship. A class indirectly contains the another object. It means contains a pointer or reference is said to have a HOLD-A relationship. Hold A Relationship. class fax.. } ; class modem fax *connect; long bps; char type; Modem (long s, fax * c) : connect (c) Bps = s; }
Base class or Super class. Subclass or Derived class
INHERITANCE is the capability of one class to inherit the properties from another class. generates a model that is closer to the real world. NEED FOR INHERITANCE 1 Closeness with the real world model 3
More informationCHAPTER 9 INHERITANCE. 9.1 Introduction
CHAPTER 9 INHERITANCE 9.1 Introduction Inheritance is the most powerful feature of an object oriented programming language. It is a process of creating new classes called derived classes, from the existing
More informationSahaj Computer Solutions OOPS WITH C++
Chapter 6 1 Contents Introduction Types of Inheritances Defining the Derived Class Single Inheritance Making a private data inheritable Multilevel Inheritance Multiple Inheritance Ambiguity Resolution
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationOOP. Unit:3.3 Inheritance
Unit:3.3 Inheritance Inheritance is like a child inheriting the features of its parents. It is a technique of organizing information in a hierarchical (tree) form. Inheritance allows new classes to be
More informationData type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:
Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before
More informationC++ 8. Constructors and Destructors
8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of
More informationINHERITANCE: EXTENDING CLASSES
INHERITANCE: EXTENDING CLASSES INTRODUCTION TO CODE REUSE In Object Oriented Programming, code reuse is a central feature. In fact, we can reuse the code written in a class in another class by either of
More informationCS304 Object Oriented Programming Final Term
1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing
More informationOBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak
OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction
More informationThe mechanism that allows us to extend the definition of a class without making any physical changes to the existing class is called inheritance.
Class : BCA 3rd Semester Course Code: BCA-S3-03 Course Title: Object Oriented Programming Concepts in C++ Unit III Inheritance The mechanism that allows us to extend the definition of a class without making
More informationObject Oriented Programming
Object Oriented Programming in C++ CHAPTER 01 Introduction to OOP & C++ Difference between Procedure Oriented and Object Oriented Programming Procedure Oriented Programming Object Oriented Programming
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat
Classes Chapter 4 Classes and Objects Data Hiding and Encapsulation Function in a Class Using Objects Static Class members Classes Class represents a group of Similar objects A class is a way to bind the
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationmywbut.com Inheritance
Inheritance 1 Inheritance is one of the cornerstones of OOP because it allows the creation of hierarchical classifications. Using inheritance, you can create a general class that defines traits common
More informationpublic : int min, hour ; T( ) //here constructor is defined inside the class definition, as line function. { sec = min = hour = 0 ; }
. CONSTRUCTOR If the name of the member function of a class and the name of class are same, then the member function is called constructor. Constructors are used to initialize the object of that class
More informationDepartment of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List
More informationObject Oriented Programming. Solved MCQs - Part 2
Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What
More informationCLASSES AND OBJECTS IN JAVA
Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class
More informationJayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT
CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions
More informationPROGRAMMING LANGUAGE 2
31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It
More informationJAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)
Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202
More informationConstructors and Destructors. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Constructors and Destructors OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani A constructor guarantees that an object created by the class will be initialized automatically. Ex: create an object integer
More informationInheritance. Transitivity
Inheritance Classes can be organized in a hierarchical structure based on the concept of inheritance Inheritance The property that instances of a sub-class can access both data and behavior associated
More informationOOP THROUGH C++(R16) int *x; float *f; char *c;
What is pointer and how to declare it? Write the features of pointers? A pointer is a memory variable that stores the address of another variable. Pointer can have any name that is legal for other variables,
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationJAVA GUI PROGRAMMING REVISION TOUR III
1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)
More informationInheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes
Inheritance Inheritance is the mechanism of deriving new class from old one, old class is knows as superclass and new class is known as subclass. The subclass inherits all of its instances variables and
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationTHE NAME OF THE CONSTRUCTOR AND DESTRUCTOR(HAVING (~) BEFORE ITS NAME) FUNCTION MUST BE SAME AS THE NAME OF THE CLASS IN WHICH THEY ARE DECLARED.
Constructor and Destructor Member Functions Constructor: - Constructor function gets invoked automatically when an object of a class is constructed (declared). Destructor:- A destructor is a automatically
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationOBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2
UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, overloading using friends, rules for operator overloading, type conversions
More informationInheritance: Single level inheritance:
Inheritance: The mechanism of deriving a new class from old one is called inheritance. The old class is referred to as the base class or parent class and the new class is called the derived class or child
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationC++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming
More informationI BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++
No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)
More informationObject Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year
Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures
More informationIBS Technical Interview Questions
IBS Technical Interview Questions IBS Technical interview Questions mainly from C,C++ and DBMS. In Technical interview, be prepared about your favorite subject. Suppose they asked, Which is your favorite
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationInternational Journal of Advance Research in Computer Science and Management Studies
Volume 3, Issue 1, January 2015 ISSN: 2321 7782 (Online) International Journal of Advance Research in Computer Science and Management Studies Research Article / Survey Paper / Case Study Available online
More informationIntro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.
Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype
More informationPadasalai.Net s Model Question Paper
Padasalai.Net s Model Question Paper STD: XII VOLUME - 2 MARKS: 150 SUB: COMPUTER SCIENCE TIME: 3 HRS PART I Choose the correct answer: 75 X 1 = 75 1. Which of the following is an object oriented programming
More information7. C++ Class and Object
7. C++ Class and Object 7.1 Class: The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member
More informationExample : class Student { int rollno; float marks; public: student( ) //Constructor { rollno=0; marks=0.0; } //other public members };
Constructors A Member function with the same name as its classis called Constructor and it is used to initilize the objects of that class type with a legal value. A Constructor is a special member function
More informationOOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.
OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding: Every
More informationCSC1322 Object-Oriented Programming Concepts
CSC1322 Object-Oriented Programming Concepts Instructor: Yukong Zhang February 18, 2016 Fundamental Concepts: The following is a summary of the fundamental concepts of object-oriented programming in C++.
More informationDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING OBJECT ORIENTED PROGRAMMING CLASS : THIRD SEMESTER CSE
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING OBJECT ORIENTED PROGRAMMING CLASS : THIRD SEMESTER CSE UNIT I 1. State the characteristics of procedure oriented programming. Emphasis is on algorithm. Large
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4&5: Inheritance Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword @override keyword
More informationMaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB CODE / SUBJECT: CS1203 / Object oriented programming YEAR / SEM: II / III QUESTION BANK UNIT I FUNDAMENTALS PART-A (2 MARKS) 1. What is Object Oriented
More informationCS304 Object Oriented Programming
1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?
More informationObject Oriented Programming in C++ Basics of OOP
Object Oriented Programming in C++ Basics of OOP In this section we describe the three most important areas in object oriented programming: encapsulation, inheritance and polymorphism. 1. INTRODUCTION
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins
More informationASSIGNMENT NO 13. Objectives: To learn and understand concept of Inheritance in Java
Write a program in Java to create a player class. Inherit the classes Cricket_player, Football_player and Hockey_player from player class. The objective of this assignment is to learn the concepts of inheritance
More informationData Abstraction. Hwansoo Han
Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed
More informationINHERITANCE DEFINING DERIVE CLASS :
INHERITANCE Inheritance Inheritance is a way or technique or method which is use to acquire the properties and methods of old class in to newly created class. Inheritance is the process by which one object
More informationOBJECTS. An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently.
OBJECTS An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently. Objects that work in associations with each others. Objects that frequently
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
More informationG52CPP C++ Programming Lecture 13
G52CPP C++ Programming Lecture 13 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture Function pointers Arrays of function pointers Virtual and non-virtual functions vtable and
More informationBasics of Object Oriented Programming. Visit for more.
Chapter 4: Basics of Object Oriented Programming Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra,
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationAssoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Inheritance A form of software reuse in which a new class is created by absorbing an existing class s members and enriching them with
More informationData Structures using OOP C++ Lecture 3
References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.
More informationModule 10 Inheritance, Virtual Functions, and Polymorphism
Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:
More informationUNIT - IV INHERITANCE AND FORMATTED I/O
UNIT - IV INHERITANCE AND FORMATTED I/O CONTENTS: Inheritance Public, private and protected derivations Multiple inheritance Virtual base class Abstract class Composite objects Runtime polymorphism\ Virtual
More informationChapter 5. Inheritance
Chapter 5 Inheritance Objectives Know the difference between Inheritance and aggregation Understand how inheritance is done in Java Learn polymorphism through Method Overriding Learn the keywords : super
More informationFast Introduction to Object Oriented Programming and C++
Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming
More informationConstructor - example
Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever
More informationDELHI PUBLIC SCHOOL, Durgapur QUESTION BANK & REVISION SHEET OF COMPUTER FOR FINAL EXAMINATION ( ) CLASS-VIIi Computer CHAPTER-CREATING MY
DELHI PUBLIC SCHOOL, Durgapur QUESTION BANK & REVISION SHEET OF COMPUTER FOR FINAL EXAMINATION (2017-18) CLASS-VIIi Computer CHAPTER-CREATING MY FIRST VIDEO, CREATING A DOCUMENTARY, APPLYING SPECIAL EFFECTS
More informationChapter 10. Class & Objects in JAVA. By: Deepak Bhinde PGT Com.Sc.
Chapter 10 Class & Objects in JAVA By: Deepak Bhinde PGT Com.Sc. Objective In this presentation you will learn about the classes and objects which leads to Object Oriented Programming (OOP) in tha JAVA.
More informationC++ Addendum: Inheritance of Special Member Functions. Constructors Destructor Construction and Destruction Order Assignment Operator
C++ Addendum: Inheritance of Special Member Functions Constructors Destructor Construction and Destruction Order Assignment Operator What s s Not Inherited? The following methods are not inherited: Constructors
More informationProgramming, numerics and optimization
Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428
More informationComputer Programming Inheritance 10 th Lecture
Computer Programming Inheritance 10 th Lecture 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2015 Eom, Hyeonsang All Rights Reserved 순서 Inheritance
More informationJava: introduction to object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationINHERITANCE - Part 1. CSC 330 OO Software Design 1
INHERITANCE - Part 1 Introduction Basic Concepts and Syntax Protected Members Constructors and Destructors Under Inheritance Multiple Inheritance Common Programming Errors CSC 330 OO Software Design 1
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationMake Classes Useful Again
Make Classes Useful Again CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 11 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationIBS Software Services Technical Interview Questions. Q1. What is the difference between declaration and definition?
IBS Software Services Technical Interview Questions Q1. What is the difference between declaration and definition? The declaration tells the compiler that at some later point we plan to present the definition
More informationUNIT III- INHERITANCE AND POLYMORPHISM
UNIT III- INHERITANCE AND POLYMORPHISM Objectives: To introduce Inheritance in C++ and to explain its importance. To make understand the different types of inheritance. To define typing conversion and
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More information(11-1) OOP: Inheritance in C++ D & D Chapter 11. Instructor - Andrew S. O Fallon CptS 122 (October 29, 2018) Washington State University
(11-1) OOP: Inheritance in C++ D & D Chapter 11 Instructor - Andrew S. O Fallon CptS 122 (October 29, 2018) Washington State University Key Concepts Base and derived classes Protected members Inheritance
More informationcout<< \n Enter values for a and b... ; cin>>a>>b;
CHAPTER 8 CONSTRUCTORS AND DESTRUCTORS 8.1 Introduction When an instance of a class comes into scope, a special function called the constructor gets executed. The constructor function initializes the class
More informationCSE202-Lec#4. CSE202 C++ Programming
CSE202-Lec#4 Functions and input/output streams @LPU CSE202 C++ Programming Outline Creating User Defined Functions Functions With Default Arguments Inline Functions @LPU CSE202 C++ Programming What is
More informationDownloaded from
Unit I Chapter -1 PROGRAMMING IN C++ Review: C++ covered in C++ Q1. What are the limitations of Procedural Programming? Ans. Limitation of Procedural Programming Paradigm 1. Emphasis on algorithm rather
More informationCpt S 122 Data Structures. Inheritance
Cpt S 122 Data Structures Inheritance Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Base Classes & Derived Classes Relationship between
More informationIT101. Inheritance, Encapsulation, Polymorphism and Constructors
IT101 Inheritance, Encapsulation, Polymorphism and Constructors OOP Advantages and Concepts What are OOP s claims to fame? Better suited for team development Facilitates utilizing and creating reusable
More informationObject-Oriented Principles and Practice / C++
Object-Oriented Principles and Practice / C++ Alice E. Fischer September 26, 2016 OOPP / C++ Lecture 4... 1/33 Global vs. Class Static Parameters Move Semantics OOPP / C++ Lecture 4... 2/33 Global Functions
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationFriend Functions, Inheritance
Friend Functions, Inheritance Friend Function Private data member of a class can not be accessed by an object of another class Similarly protected data member function of a class can not be accessed by
More informationCOIMBATORE EDUCATIONAL DISTRICT
COIMBATORE EDUCATIONAL DISTRICT REVISION EXAMINATION JANUARY 2015 STD-12 COMPUTER SCIENCE ANSEWR KEY PART-I Choose the Correct Answer QNo Answer QNo Answer 1 B Absolute Cell Addressing 39 C Void 2 D
More informationInheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object.
Inheritance in Java 1. Inheritance 2. Types of Inheritance 3. Why multiple inheritance is not possible in java in case of class? Inheritance in java is a mechanism in which one object acquires all the
More informationClasses. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).
UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members
More informationC++ Basic Syntax. Constructors and destructors. Wojciech Frohmberg / OOP Laboratory. Poznan University of Technology
Constructors and destructors 1 1 Department of Computer Science Poznan University of Technology 2012.10.07 / OOP Laboratory Outline 1 2 3 4 5 Outline 1 2 3 4 5 Outline 1 2 3 4 5 Outline 1 2 3 4 5 Outline
More informationObject-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationCPSC 427a: Object-Oriented Programming
CPSC 427a: Object-Oriented Programming Michael J. Fischer Lecture 16 November 1, 2012 CPSC 427a, Lecture 16 1/29 Unicode Characters and PS7 Name Visibility CPSC 427a, Lecture 16 2/29 Unicode Characters
More informationLecture 18 CSE11 Fall 2013 Inheritance
Lecture 18 CSE11 Fall 2013 Inheritance What is Inheritance? Inheritance allows a software developer to derive a new class from an existing one write code once, use many times (code reuse) Specialization
More information