Skip to content
CramShare
PremiumStudy notes

Extended classes using inheritance

ITH105 Programming in c · Shivaji university

Updated today

Complete, exam-oriented notes for IT/Computer Diploma students Covers Inheritance introduction, purpose, syntax, visibility modes (public, private, protected) with table,Single,Multiple,Hierarchical,Multilevel,Hybrid (corrected example), Multipath &Problem, Virtual Base Classes&pure virtual function

Pages
17
Academic year
2025/2026
Language
English

What’s included

Preview 3 of 17 pages

See the first 3 pages exactly as they appear in the document.

Read page 1 as text

GOVERNMENT POLYTECHNIC KOLHAPUR (Autonomous) - Information Technology C++ Programming CHAPTER 04 Unit lll: . Extending Classes . . Using Inheritance Corrected, Complete & Exam-Oriented Notes Based on original classroom notes - preserved topic order, corrected for modern C++ (GCC / Dev-C++). No Turbo C++ functions like clrscr(), getch(), conio.h or <iostream.h> are used. Contents: Inheritance Intro | Visibility Modes | Single | Multiple | Hierarchical | Multilevel | Hybrid | Multipath | Virtual Base Class | Abstract Class | Constructors in Derived Classes | Order of Constructor Execution How to use: Read definition -> see diagram -> read program line-by-line -> run it yourself -> remember Exam Point box. Student-prepared notes - For study purpose

Read page 2 as text

1 Inheritance - Introduction Definition: Inheritance is the capability of one class to acquire properties and characteristics from another class. The class whose properties are inherited is called Parent / Base / Super class. The class which inherits is called Child / Derived / Sub class. Inheritance makes code reusable. When we inherit an existing class, all its methods and fields become available in the new class, hence code is reused. Example: Vehicle has start() and stop(). Car inherits Vehicle, so Car also gets start() and stop() without writing them again. Purpose of Inheritance - 1. Code Reusability - Write once, use in many classes. + 2. Method Overriding - Derived class can redefine base class function (hence Runtime Polymorphism). + 3. Use of Virtual Keyword - For virtual functions and virtual base classes. Defining a Derived Class - Syntax of Inheritance Syntax - Inheritance class Subclass_name : access_mode Superclass_name { // body of subclass bi While defining a derived class, the base class must be already defined or at least declared before the derived class declaration. Visibility Modes and Effects Access Mode specifies in which mode properties of superclass will be inherited into subclass - public, private or protected. 1) Public Inheritance - Most used mode Protected member of super class becomes protected in sub class, and public becomes public. Syntax - Public class Subclass : public Superclass [i // body 177 2) Private Inheritance - Default in C++ Protected and public members of super class become private members of derived class. Syntax - Private class Subclass : Superclass // By default private [ // body Vi // Same as: class Subclass : private Superclass 3) Protected Inheritance Public and protected members of super class become protected members of sub class.

Read page 3 as text

Syntax - Protected class Subclass : protected Superclass ( // body bi Table Showing All Visibility Modes Private Not Inherited Not Inherited Not Inherited Protected Protected Private Protected Public Public Private Protected Note: Private members of base class are NEVER inherited in any mode. They can only be accessed through public / protected functions of base class. Exam Point - If question asks "What happens to public members in private inheritance?" Answer: They become private in derived class. They can be used inside derived class, but not from outside using derived object.

14 more pages after this

You’ve read 3 of 17. Unlock once and it stays in your library — and if the rest doesn’t match what you just read, you get a refund.

$5.80

Yours permanently