SlideShare a Scribd company logo
  INHERITANCE
DEFINATION Inheritance  is a mechanism of creating new classes called derived class from existing ones i.e. base classes. Inheritance is a most powerful feature of object oriented programming.
Types of Inheritance Single Inheritance Multiple Inheritance Multilevel Inheritance Hierarchical Inheritance Hybrid Inheritance
SINGLE INHERITANCE When a derived class inherits only from one base class ,it is Known  as single Inheritance. Base Class Derived Class  A B
When a derived class inherit from multiple base classes it is known as multiple Inheritance. A B C MULTIPLE INHERITANCE Base Class Derived Class
MULTILEVEL INHERITANCE When a derived class inherit from a class that itself inherits from other class , it is known as multilevel Inheritance. Base Class Derived Class of x Base Class of z Derived Class A B C
HYBRID   INHERITANCE Hybrid Inheritance combines two or more forms of Inheritance. w x y z
HIERARCHICAL INHERITANCE When many derived classes inherit from a single base class , it is known as hierarchical Inheritance. Base Class Derived classes a b c d
A general form to defining a derived class is: Class derived class name: visibility mode  base class  name {  members of derived class }  ; Class ABC: public XYZ {  members of ABC };  DEFINING DERIVED CLASS
Example of derived class definition is: Class Sub : public Super  \\ public derivation {  ……… \\ members of sub }; Class Sub: private Super  \\ private derivation { …… ... \\ members of sub }; Class Sub: protected Super  \\ protected derivation { …… ... \\ members of sub };
MULTIPLE INHERITANCE Example of derived class definition is: Class derived_class : vis_mode base1, vis_mode base 2 { ………… . \\ members of derived class }; Class Sub : public SuperA, private SuperB {  ……… \\ members of sub };
Visibility Modes DEFINATION:- Visibility Mode specifies whether the features of the base class are privately derived or publicly derived or protected derived. Public Visibility Mode - It means that the derived class can access the public and protected members of the base class. The public members of the base class become the public member of the derived class, and the protected member of the base class become the protected member of the derived class.
Private Visibility Mode-   The public and protected members of the base class become private members of the derived class. The inherited members can only be accessed only through the member function of derived class. Protected Visibility Mode-   The public and protected members of base class become protected members of the derived class.
Visibility of Inherited base class members in Derived Class. Visibility Mode Public members of base class becomes Protected members of base class becomes Private members of the base class is not accessible to the derived class. Public Public Protected Protected Protected Protected Private Private Private
Accessibility of Base class members  No No Yes Private No Yes Yes Protected Yes Yes Yes Public Accessible from objects outside class Accessible from derived class Accessible from own class Access Specifier
Inheritance and Constructors and Destructors  When an object of a derived class is created, the program first calls the constructor for base class. When an object expires, the program first calls the derived destructor and then base destructor
Class super  { …… . }; Class Sub : public Super  { ….. }; int main() {  sub ob1; …… . }
Base class Constructors Base class constructor require arguments to construct their objects. It is the responsibility of derived class constructor to pass those arguments to base class. Syntax : Derived ::Derived (type1 x, type2 y ….) : base (x , y) { … .. }
Class Base { int a;  float b; public : Base(int I, float j) { a = i;  b = j; } … }; Class Derived : public Base {…. Public :  Derived ( int p, float q) : Base (p , q)  {  } }; Even if derived const does not need a parameter, yet it accepts parameter for base const.
Class Base { int a;  float b; public : Base( int i, float j) { a = i;  b = j; } … }; Class Derived : public Base { int x; float y; Public :  Derived ( int i, int j , int p, float q) : Base (p , q)  {  x = i ; Y = j ;  } }; Derived Const is accepting parameter for itself( i ,j) and ( p , q) for Base const
Constructor in Derived Class # include<iostream.h> class alpha {  protected:  int x; alpha(int i) { x=i; } }; class beta {  protected: float y; Beta(float j) {   y=j; } };
Class gamma: public beta, public alpha { int k; public: gamma(int a,float b, int c): alpha(a) , beta(b) { k=c; } void show() { cout<<“1”<<x<<“2”<<y<<“3”<<k; }}; void main() { gamma g(14,15.2,17); g.show(); }
Facts about inheritance Private members of a base class are not directly accessible in the derived class. Example  int test; \\ Global variable Class base {  int test; \\ private members of base   public:  void getit() {  cin>> test; }   }; Class derived : public base  {  public : void check ( ) {  test++;  } \\ not allowed  };
When a class is derived publicly, you cannot selectively deny access to base members by declaring them in derived private section of the derived class. Example  Class base { Public : int x,y,z; }; Class derived : public base  {  Public: int a; Private : Base :: x; // Invalid  }
When you derive a class privately, you can selectively allow access to some of the base members. To allow access to some of the inherited members, you can selectively declare some of the base class members in the public section of the privately derived class. Example  Class base  { Public : int x,y,z; }; Class derived : private base  {  Public: int a; Base :: x; \\Valid } Or  Public : Using Base :: x ;
Abstract class A class that serves only as a base class from which other classes can be derived, but no objects of this base type exist, is known as abstract class.
Constructors in Multiple inheritance As long as no base class constructor takes any arguments, the derived class need not have a constructor function. However, if a base class contains a constructor with one or more arguments, then it is mandatory for the derived class to have a constructor and pass the arguments to the base constructor. In multiple inheritance , the base classes are constructed in the order in which they appear in the declaration of the derived class. Example  Class Base1  {  protected :  int a; public : Base1(int x)  {  a = x;  cout<<“Constructing Base 1”; } ~Base1( ) {  cout<<“Destructing Base1”;  } };
Class base2  {  Protected : int b; public : Base2(int y) {  b = y;  cout<<“Constructing Base2”;  } ~Base2 ( ) {  cout<< Destructing Base2 “;  } }; Class derived : public Base2, public Base1 {  int c; public :  derived (int I, int j, int k): Base2(i), Base1(j) { c = k;  cout <<“Constructing Derived”;  }
~ Derived ( ) {  cout << Destructing Derived “;  } Void show( ) {  cout <<“1.”<<a<<“\t 2.”<<b <<“\t 3.”<<c;  } }; Int main ( ) {  Clrscr(); Derived ob(14,15,16); Ob.show(); } OUTPUT : Constructing Base2 Constructing Base1 Constructing Derived 15 2.  14  3.  16 Destructing Derived  Destructing Base1 Destructing Base2
Virtual Base class Example  Class Base  {  public : int a ; }; Class D1 : public Base  \\ D1 inherits Base {  public : int b ; }; Class D2 : public Base  \\ D2 inherits Base {  public : int c ; }; Class D3 : public D1, public D2 \\ D3 inherits D1 and D2 {  public :  int total; }; Void main ( ) { D3 ob; ob.a = 25 \\ this is ambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; }
To Use Scope resolution operator to a Void main ( ) { D3 ob; ob.D1 :: a = 25 \\ scope resolved Ob.b = 50; Ob.c = 75; Ob.total = ob.D1 :: a +ob.b + ob.c; Cout <<ob.D1 :: a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; } Remedy
To Use a keyword  Virtual  Example  Class Base  {  public : int a ; }; Class D1 : virtual public Base  \\ D1 inherits Base as Virtual  {  public : int b ; }; Class D2 : virtual public Base  {  public : int c ; }; Class D3 : public D1, public D2 \\ this time only one copy of base {  public :  int total; };
Void main ( ) { D3 ob; ob.a = 25 \\  now unambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; }
Example of Multilevel Inheritance   #include<iostream.h>   class student   {   protected:     int roll_number;   public:   void get_number()   {   cout<<&quot;Enter rollno&quot;;   cin>>roll_number;   }     void putnumber()   {     cout<<roll_number;   }   };
class test: public student {   protected:   float sub1;   float sub2;   public:   void getmarks()   {   cout<<&quot;enter the marks of sub1,sub2&quot;;   cin>>sub1>>sub2;   }   void putmarks()   {   cout<<&quot;marks in sub1=&quot;<<sub1;   cout<<&quot;marks in sub2=&quot;<<sub2;   } };
class result : public test {   float total;   public:   void display(void)   {    total=sub1+sub2;   putnumber();   putmarks();   cout<<&quot;Total&quot;<<total;   }   };   void main()   {   result a;   a.get_number();   a.getmarks();   a.display();   }
  ANY QUERY   THANK YOU

More Related Content

PPSX
PPTX
Classes in c++ (OOP Presentation)
PPTX
Inheritance in c++
PPTX
inheritance
PPTX
Java access modifiers
PPTX
Destructors
PPTX
Inheritance ppt
PDF
Constructors and Destructors
Classes in c++ (OOP Presentation)
Inheritance in c++
inheritance
Java access modifiers
Destructors
Inheritance ppt
Constructors and Destructors

What's hot (20)

PPTX
Oops concept in c++ unit 3 -topic 4
PPTX
Multiple inheritance
PPT
Polymorphism
PPTX
[OOP - Lec 07] Access Specifiers
PPT
Inheritance OOP Concept in C++.
PDF
Classes and Nested Classes in Java
PPTX
Inheritance in c++
PPT
Serialization/deserialization
PPTX
Inheritance and Polymorphism in java simple and clear
PPT
Data members and member functions
PPTX
Advance oops concepts
PPTX
Inheritance in oops
PPTX
array of object pointer in c++
PPT
C++ Inheritance
PPTX
Classes and objects in c++
PPTX
Inheritance in Object Oriented Programming
PPTX
inheritance c++
PPTX
Single inheritance
PPTX
Python decorators
PPTX
5. stored procedure and functions
Oops concept in c++ unit 3 -topic 4
Multiple inheritance
Polymorphism
[OOP - Lec 07] Access Specifiers
Inheritance OOP Concept in C++.
Classes and Nested Classes in Java
Inheritance in c++
Serialization/deserialization
Inheritance and Polymorphism in java simple and clear
Data members and member functions
Advance oops concepts
Inheritance in oops
array of object pointer in c++
C++ Inheritance
Classes and objects in c++
Inheritance in Object Oriented Programming
inheritance c++
Single inheritance
Python decorators
5. stored procedure and functions
Ad

Viewers also liked (20)

PPTX
Inheritance
PPTX
Inheritance
PPTX
Inheritance in JAVA PPT
PPT
Inheritance, Object Oriented Programming
PPSX
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
PPTX
Inheritance in C++
PPTX
Hierarchical inheritance
PPTX
Hybrid Inheritance in C++
PPT
Multi level hierarchy
PPT
Genetics pedigree problems
PPTX
Basis of Genetic Inheritance
PPTX
Pedigree Basics!
PPT
Pedigree analysis
PPTX
Inheritance
PPTX
pedigree analysis
PPTX
Inheritance in java
PPT
Object-Oriented Programming Using C++
PPTX
Constructors & destructors
Inheritance
Inheritance
Inheritance in JAVA PPT
Inheritance, Object Oriented Programming
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in C++
Hierarchical inheritance
Hybrid Inheritance in C++
Multi level hierarchy
Genetics pedigree problems
Basis of Genetic Inheritance
Pedigree Basics!
Pedigree analysis
Inheritance
pedigree analysis
Inheritance in java
Object-Oriented Programming Using C++
Constructors & destructors
Ad

Similar to Inheritance (20)

PPT
PDF
lecture-2021inheritance-160705095417.pdf
PPTX
[OOP - Lec 20,21] Inheritance
PPT
Inheritance, polymorphisam, abstract classes and composition)
PPT
inhertance c++
PDF
Chapter 6 and inheritance OOP C++ tu ioe
PDF
Inheritance
PPT
Inheritance
PPT
Inheritance in C++
PPTX
INHERITANCE.pptx
PPT
Lecturespecial
PPT
PPTX
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
PPT
MODULE2_INHERITANCE_SESSION1.ppt computer
PPT
Lecture 5 Inheritance
PPT
inheritance
PPTX
inheritance
PPTX
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
PPTX
OOP unit II inheritance.pptx object oriented programming
lecture-2021inheritance-160705095417.pdf
[OOP - Lec 20,21] Inheritance
Inheritance, polymorphisam, abstract classes and composition)
inhertance c++
Chapter 6 and inheritance OOP C++ tu ioe
Inheritance
Inheritance
Inheritance in C++
INHERITANCE.pptx
Lecturespecial
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
MODULE2_INHERITANCE_SESSION1.ppt computer
Lecture 5 Inheritance
inheritance
inheritance
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
OOP unit II inheritance.pptx object oriented programming

More from poonam.rwalia (7)

PPT
1 D Arrays in C++
PPT
Software Engineering
PPT
Computer Ethics
PPT
Benefits Of Computer Software
PPT
Internet
1 D Arrays in C++
Software Engineering
Computer Ethics
Benefits Of Computer Software
Internet

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Cell Types and Its function , kingdom of life
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
01-Introduction-to-Information-Management.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
RMMM.pdf make it easy to upload and study
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPH.pptx obstetrics and gynecology in nursing
Cell Types and Its function , kingdom of life
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pre independence Education in Inndia.pdf
master seminar digital applications in india
Institutional Correction lecture only . . .
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
human mycosis Human fungal infections are called human mycosis..pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Renaissance Architecture: A Journey from Faith to Humanism
01-Introduction-to-Information-Management.pdf
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Structure & Organelles in detailed.
RMMM.pdf make it easy to upload and study

Inheritance

  • 2. DEFINATION Inheritance is a mechanism of creating new classes called derived class from existing ones i.e. base classes. Inheritance is a most powerful feature of object oriented programming.
  • 3. Types of Inheritance Single Inheritance Multiple Inheritance Multilevel Inheritance Hierarchical Inheritance Hybrid Inheritance
  • 4. SINGLE INHERITANCE When a derived class inherits only from one base class ,it is Known as single Inheritance. Base Class Derived Class A B
  • 5. When a derived class inherit from multiple base classes it is known as multiple Inheritance. A B C MULTIPLE INHERITANCE Base Class Derived Class
  • 6. MULTILEVEL INHERITANCE When a derived class inherit from a class that itself inherits from other class , it is known as multilevel Inheritance. Base Class Derived Class of x Base Class of z Derived Class A B C
  • 7. HYBRID INHERITANCE Hybrid Inheritance combines two or more forms of Inheritance. w x y z
  • 8. HIERARCHICAL INHERITANCE When many derived classes inherit from a single base class , it is known as hierarchical Inheritance. Base Class Derived classes a b c d
  • 9. A general form to defining a derived class is: Class derived class name: visibility mode base class name { members of derived class } ; Class ABC: public XYZ { members of ABC }; DEFINING DERIVED CLASS
  • 10. Example of derived class definition is: Class Sub : public Super \\ public derivation { ……… \\ members of sub }; Class Sub: private Super \\ private derivation { …… ... \\ members of sub }; Class Sub: protected Super \\ protected derivation { …… ... \\ members of sub };
  • 11. MULTIPLE INHERITANCE Example of derived class definition is: Class derived_class : vis_mode base1, vis_mode base 2 { ………… . \\ members of derived class }; Class Sub : public SuperA, private SuperB { ……… \\ members of sub };
  • 12. Visibility Modes DEFINATION:- Visibility Mode specifies whether the features of the base class are privately derived or publicly derived or protected derived. Public Visibility Mode - It means that the derived class can access the public and protected members of the base class. The public members of the base class become the public member of the derived class, and the protected member of the base class become the protected member of the derived class.
  • 13. Private Visibility Mode- The public and protected members of the base class become private members of the derived class. The inherited members can only be accessed only through the member function of derived class. Protected Visibility Mode- The public and protected members of base class become protected members of the derived class.
  • 14. Visibility of Inherited base class members in Derived Class. Visibility Mode Public members of base class becomes Protected members of base class becomes Private members of the base class is not accessible to the derived class. Public Public Protected Protected Protected Protected Private Private Private
  • 15. Accessibility of Base class members No No Yes Private No Yes Yes Protected Yes Yes Yes Public Accessible from objects outside class Accessible from derived class Accessible from own class Access Specifier
  • 16. Inheritance and Constructors and Destructors When an object of a derived class is created, the program first calls the constructor for base class. When an object expires, the program first calls the derived destructor and then base destructor
  • 17. Class super { …… . }; Class Sub : public Super { ….. }; int main() { sub ob1; …… . }
  • 18. Base class Constructors Base class constructor require arguments to construct their objects. It is the responsibility of derived class constructor to pass those arguments to base class. Syntax : Derived ::Derived (type1 x, type2 y ….) : base (x , y) { … .. }
  • 19. Class Base { int a; float b; public : Base(int I, float j) { a = i; b = j; } … }; Class Derived : public Base {…. Public : Derived ( int p, float q) : Base (p , q) { } }; Even if derived const does not need a parameter, yet it accepts parameter for base const.
  • 20. Class Base { int a; float b; public : Base( int i, float j) { a = i; b = j; } … }; Class Derived : public Base { int x; float y; Public : Derived ( int i, int j , int p, float q) : Base (p , q) { x = i ; Y = j ; } }; Derived Const is accepting parameter for itself( i ,j) and ( p , q) for Base const
  • 21. Constructor in Derived Class # include<iostream.h> class alpha { protected: int x; alpha(int i) { x=i; } }; class beta { protected: float y; Beta(float j) { y=j; } };
  • 22. Class gamma: public beta, public alpha { int k; public: gamma(int a,float b, int c): alpha(a) , beta(b) { k=c; } void show() { cout<<“1”<<x<<“2”<<y<<“3”<<k; }}; void main() { gamma g(14,15.2,17); g.show(); }
  • 23. Facts about inheritance Private members of a base class are not directly accessible in the derived class. Example int test; \\ Global variable Class base { int test; \\ private members of base public: void getit() { cin>> test; } }; Class derived : public base { public : void check ( ) { test++; } \\ not allowed };
  • 24. When a class is derived publicly, you cannot selectively deny access to base members by declaring them in derived private section of the derived class. Example Class base { Public : int x,y,z; }; Class derived : public base { Public: int a; Private : Base :: x; // Invalid }
  • 25. When you derive a class privately, you can selectively allow access to some of the base members. To allow access to some of the inherited members, you can selectively declare some of the base class members in the public section of the privately derived class. Example Class base { Public : int x,y,z; }; Class derived : private base { Public: int a; Base :: x; \\Valid } Or Public : Using Base :: x ;
  • 26. Abstract class A class that serves only as a base class from which other classes can be derived, but no objects of this base type exist, is known as abstract class.
  • 27. Constructors in Multiple inheritance As long as no base class constructor takes any arguments, the derived class need not have a constructor function. However, if a base class contains a constructor with one or more arguments, then it is mandatory for the derived class to have a constructor and pass the arguments to the base constructor. In multiple inheritance , the base classes are constructed in the order in which they appear in the declaration of the derived class. Example Class Base1 { protected : int a; public : Base1(int x) { a = x; cout<<“Constructing Base 1”; } ~Base1( ) { cout<<“Destructing Base1”; } };
  • 28. Class base2 { Protected : int b; public : Base2(int y) { b = y; cout<<“Constructing Base2”; } ~Base2 ( ) { cout<< Destructing Base2 “; } }; Class derived : public Base2, public Base1 { int c; public : derived (int I, int j, int k): Base2(i), Base1(j) { c = k; cout <<“Constructing Derived”; }
  • 29. ~ Derived ( ) { cout << Destructing Derived “; } Void show( ) { cout <<“1.”<<a<<“\t 2.”<<b <<“\t 3.”<<c; } }; Int main ( ) { Clrscr(); Derived ob(14,15,16); Ob.show(); } OUTPUT : Constructing Base2 Constructing Base1 Constructing Derived 15 2. 14 3. 16 Destructing Derived Destructing Base1 Destructing Base2
  • 30. Virtual Base class Example Class Base { public : int a ; }; Class D1 : public Base \\ D1 inherits Base { public : int b ; }; Class D2 : public Base \\ D2 inherits Base { public : int c ; }; Class D3 : public D1, public D2 \\ D3 inherits D1 and D2 { public : int total; }; Void main ( ) { D3 ob; ob.a = 25 \\ this is ambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; }
  • 31. To Use Scope resolution operator to a Void main ( ) { D3 ob; ob.D1 :: a = 25 \\ scope resolved Ob.b = 50; Ob.c = 75; Ob.total = ob.D1 :: a +ob.b + ob.c; Cout <<ob.D1 :: a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; } Remedy
  • 32. To Use a keyword Virtual Example Class Base { public : int a ; }; Class D1 : virtual public Base \\ D1 inherits Base as Virtual { public : int b ; }; Class D2 : virtual public Base { public : int c ; }; Class D3 : public D1, public D2 \\ this time only one copy of base { public : int total; };
  • 33. Void main ( ) { D3 ob; ob.a = 25 \\ now unambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“\t”<< ob.b<<“\t”<< ob.c<<“\t”<< ob.total<<“\t”<<“\n”; }
  • 34. Example of Multilevel Inheritance #include<iostream.h> class student { protected: int roll_number; public: void get_number() { cout<<&quot;Enter rollno&quot;; cin>>roll_number; } void putnumber() { cout<<roll_number; } };
  • 35. class test: public student { protected: float sub1; float sub2; public: void getmarks() { cout<<&quot;enter the marks of sub1,sub2&quot;; cin>>sub1>>sub2; } void putmarks() { cout<<&quot;marks in sub1=&quot;<<sub1; cout<<&quot;marks in sub2=&quot;<<sub2; } };
  • 36. class result : public test { float total; public: void display(void) { total=sub1+sub2; putnumber(); putmarks(); cout<<&quot;Total&quot;<<total; } }; void main() { result a; a.get_number(); a.getmarks(); a.display(); }
  • 37. ANY QUERY THANK YOU