SlideShare a Scribd company logo
ABSTRACT
CLASSES AND
INTERFACES
GROUP # 8
1. Adnan Haider
2. M Ismail
3. Rimsha Ali
4. Sofia Bashir
2
OVERVIEW
♦️Introduction
♦️Abstract Classes
♦️Interfaces
♦️Comparison between Abstract Classes and
Interfaces
♦️Real World Examples and use cases
3
1. INTRODUCTION:
Abstract Methods:
• The Functions that are declared in a class
but not implemented in that class are
called abstract methods .
• They Serves as placeholder for methods
that must be implemented by subclasses.
• These methods are typically declared in
abstract classes or interfaces.(Abstract
methods are achieved by declaring
virtual functions without providing any
implementation) .
• They are useful for defining a common
interface that implemented in their own
way.
CONCRETE CLASS:
 A concrete class is a class that provides
implementations for all its member functions,
including inherited abstract methods.
 It can be instantiated to create objects. Concrete
classes can also have their own non-abstract
methods and member variables.
 They serve as building blocks for creating
objects with specific behavior and attributes
PURE VIRTUAL
FUNCTION:
 “Pure virtual function is a virtual function with no body
.”
 A pure virtual function is a special type of virtual
function in C++ that is declared in a base class but has
no implementation. It is marked with = 0 at the end of its
declaration.
 Classes containing pure virtual functions are abstract
classes, meaning they cannot be instantiated directly.
Instead, they serve as interfaces or blueprints for
derived classes to provide implementations for the pure
virtual functions.
 Subclasses must override all pure virtual functions to
become concrete classes and be instantiated. Pure
virtual functions are a key feature of achieving
polymorphism and defining abstract interfaces in C++. 6
ABSTRACT
CLASSES:
• “The classes that contain pure virtual
functions are called abstract classes”
• These classes can not be instantiated
directly ; they are meant to be subclassed.
• Abstracts methods are declared but not
implemented in the abstract class itself.
• It serves as blueprints for other classes and
can contain one or more abstract methods.
7
​SYNTAX
EXAMPLE
: #include <iostream>
// Abstract class
class Shape
{ public:
// Pure virtual function (abstract method)
virtual void draw() = 0;
};
int main() {
// Attempting to create an object of the abstract
class will result in a compilation error // Shape
shape;
return 0;}
.
8
EXAMPLE:
#include <iostream>// Abstract class
using namespace std;
class Shape {
public: // Abstract method
virtual void draw() = 0; };
// Concrete subclass implementing the abstract method
class Circle :
public Shape {public:
void draw() override {
cout << "Drawing Circlen"; }}
;// Concrete subclass implementing the abstract method
class Rectangle :
public Shape {public:
void draw() override {
cout << "Drawing Rectanglen"; }}; 9
EXAMPLE:
int main()
{ // Create objects of concrete subclasses
Circle circle;
Rectangle rectangle; // Call methods
circle.draw();
rectangle.draw();
return 0;
}
10
output:
Drawing Circle
Drawing Rectangle
INTERFACES:
• “An interface is a blueprint that defines a set of
methods and properties that a class must implement
,without providing the actual implementation”.
• interfaces are typically defined using abstract classes
with pure virtual functions.
• An abstract class is a class that cannot be instantiated
on its own and contains one or more pure virtual
functions, which are declared using the virtual keyword
followed by = 0; syntax.
11
EXAMPLE
:
#include <iostream>
Using namespace std;
class Interface {
public:
virtual void method1() = 0;
virtual void method2() = 0;};
class MyClass :
public Interface {public:
void method1() {
cout << "Inside method1n"; }
void method2() {
cout << "Inside method2n"; }};
int main() {
MyClass obj;
obj.method1();
obj.method2(); return 0;
}
1. .
12
OUTPUT:
Inside method1
Inside method2
RULE OF INTERFACES:
13
Interfaces in OOP define what classes can do
without providing any implementation details,
while abstract classes can provide both
method declarations and some
implementations but cannot be instantiated
directly.
ABSTRACT CLASS
a)Abstract class contain both
virtual methods and concrete
methods(with
implementations)
b)These cannot be instantiated
directly.
c) Abstract Classes Support
Single inheritance.
d)Abstract classes are used
when a base class needs to
provide some default
behavior along with abstract
methods that subclasses
must implement.
a) Interfaces contain only pure
virtual methods (method without
implementations).
b) These also cannot be
instantiated at all.
c) Interfaces support multiple
inheritance
d) Interfaces are used when
defining a common behavior of
multiple functions or methods.
INTERFACES
REAL WORLD EXAMPLE:
• .
Virtual void getName()=0;
Void getName()
{
}
Void getName()
{
}
Class Manager Class Accountant Class Costumer
Virtual void
getName()=0;
Class Database
ADVANTAGES IN OOP:
1. Defining a Common Interface: Abstract classes set a
blueprint for subclasses, ensuring they share common
methods.
2. Organizing Code: They help group related classes
under a common umbrella, improving code structure.
3. Extending Functionality: New features can be easily
added by creating new subclasses of abstract classes.
4. Enhancing Maintainability: Abstract classes make
code easier to understand and maintain by
encapsulating related behavior. 16

More Related Content

Similar to abstract classes and interfaces in c++\ by M adnan Haider MNSUAM.pptx

8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#
Sireesh K
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
MOHIT AGARWAL
 
Java basics
Java basicsJava basics
Java basics
Shivanshu Purwar
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
colleges
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
Umar Farooq
 
Abstract Class and Interface.pdf
Abstract Class and Interface.pdfAbstract Class and Interface.pdf
Abstract Class and Interface.pdf
rajaratna4
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & Interface
Linh Lê
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
Ganesh Samarthyam
 
abstract class and interface.Net
abstract class and interface.Netabstract class and interface.Net
abstract class and interface.Net
BGSBU Rajouri
 
Java Unit 2(part 3)
Java Unit 2(part 3)Java Unit 2(part 3)
Java Unit 2(part 3)
SURBHI SAROHA
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptx
AsifMulani17
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Sujit Kumar
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
G C Reddy Technologies
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
mcollison
 
A1869984431_21789_28_2018_Abstract Class.ppt
A1869984431_21789_28_2018_Abstract Class.pptA1869984431_21789_28_2018_Abstract Class.ppt
A1869984431_21789_28_2018_Abstract Class.ppt
RithwikRanjan
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
Gaurav Mehta
 

Similar to abstract classes and interfaces in c++\ by M adnan Haider MNSUAM.pptx (20)

8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Java basics
Java basicsJava basics
Java basics
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
 
Abstract Class and Interface.pdf
Abstract Class and Interface.pdfAbstract Class and Interface.pdf
Abstract Class and Interface.pdf
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & Interface
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
abstract class and interface.Net
abstract class and interface.Netabstract class and interface.Net
abstract class and interface.Net
 
Java Unit 2(part 3)
Java Unit 2(part 3)Java Unit 2(part 3)
Java Unit 2(part 3)
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptx
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
A1869984431_21789_28_2018_Abstract Class.ppt
A1869984431_21789_28_2018_Abstract Class.pptA1869984431_21789_28_2018_Abstract Class.ppt
A1869984431_21789_28_2018_Abstract Class.ppt
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 

Recently uploaded

办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
apvysm8
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
zsjl4mimo
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
Walaa Eldin Moustafa
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
kuntobimo2016
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 

Recently uploaded (20)

办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 

abstract classes and interfaces in c++\ by M adnan Haider MNSUAM.pptx

  • 2. GROUP # 8 1. Adnan Haider 2. M Ismail 3. Rimsha Ali 4. Sofia Bashir 2
  • 3. OVERVIEW ♦️Introduction ♦️Abstract Classes ♦️Interfaces ♦️Comparison between Abstract Classes and Interfaces ♦️Real World Examples and use cases 3
  • 4. 1. INTRODUCTION: Abstract Methods: • The Functions that are declared in a class but not implemented in that class are called abstract methods . • They Serves as placeholder for methods that must be implemented by subclasses. • These methods are typically declared in abstract classes or interfaces.(Abstract methods are achieved by declaring virtual functions without providing any implementation) . • They are useful for defining a common interface that implemented in their own way.
  • 5. CONCRETE CLASS:  A concrete class is a class that provides implementations for all its member functions, including inherited abstract methods.  It can be instantiated to create objects. Concrete classes can also have their own non-abstract methods and member variables.  They serve as building blocks for creating objects with specific behavior and attributes
  • 6. PURE VIRTUAL FUNCTION:  “Pure virtual function is a virtual function with no body .”  A pure virtual function is a special type of virtual function in C++ that is declared in a base class but has no implementation. It is marked with = 0 at the end of its declaration.  Classes containing pure virtual functions are abstract classes, meaning they cannot be instantiated directly. Instead, they serve as interfaces or blueprints for derived classes to provide implementations for the pure virtual functions.  Subclasses must override all pure virtual functions to become concrete classes and be instantiated. Pure virtual functions are a key feature of achieving polymorphism and defining abstract interfaces in C++. 6
  • 7. ABSTRACT CLASSES: • “The classes that contain pure virtual functions are called abstract classes” • These classes can not be instantiated directly ; they are meant to be subclassed. • Abstracts methods are declared but not implemented in the abstract class itself. • It serves as blueprints for other classes and can contain one or more abstract methods. 7
  • 8. ​SYNTAX EXAMPLE : #include <iostream> // Abstract class class Shape { public: // Pure virtual function (abstract method) virtual void draw() = 0; }; int main() { // Attempting to create an object of the abstract class will result in a compilation error // Shape shape; return 0;} . 8
  • 9. EXAMPLE: #include <iostream>// Abstract class using namespace std; class Shape { public: // Abstract method virtual void draw() = 0; }; // Concrete subclass implementing the abstract method class Circle : public Shape {public: void draw() override { cout << "Drawing Circlen"; }} ;// Concrete subclass implementing the abstract method class Rectangle : public Shape {public: void draw() override { cout << "Drawing Rectanglen"; }}; 9
  • 10. EXAMPLE: int main() { // Create objects of concrete subclasses Circle circle; Rectangle rectangle; // Call methods circle.draw(); rectangle.draw(); return 0; } 10 output: Drawing Circle Drawing Rectangle
  • 11. INTERFACES: • “An interface is a blueprint that defines a set of methods and properties that a class must implement ,without providing the actual implementation”. • interfaces are typically defined using abstract classes with pure virtual functions. • An abstract class is a class that cannot be instantiated on its own and contains one or more pure virtual functions, which are declared using the virtual keyword followed by = 0; syntax. 11
  • 12. EXAMPLE : #include <iostream> Using namespace std; class Interface { public: virtual void method1() = 0; virtual void method2() = 0;}; class MyClass : public Interface {public: void method1() { cout << "Inside method1n"; } void method2() { cout << "Inside method2n"; }}; int main() { MyClass obj; obj.method1(); obj.method2(); return 0; } 1. . 12 OUTPUT: Inside method1 Inside method2
  • 13. RULE OF INTERFACES: 13 Interfaces in OOP define what classes can do without providing any implementation details, while abstract classes can provide both method declarations and some implementations but cannot be instantiated directly.
  • 14. ABSTRACT CLASS a)Abstract class contain both virtual methods and concrete methods(with implementations) b)These cannot be instantiated directly. c) Abstract Classes Support Single inheritance. d)Abstract classes are used when a base class needs to provide some default behavior along with abstract methods that subclasses must implement. a) Interfaces contain only pure virtual methods (method without implementations). b) These also cannot be instantiated at all. c) Interfaces support multiple inheritance d) Interfaces are used when defining a common behavior of multiple functions or methods. INTERFACES
  • 15. REAL WORLD EXAMPLE: • . Virtual void getName()=0; Void getName() { } Void getName() { } Class Manager Class Accountant Class Costumer Virtual void getName()=0; Class Database
  • 16. ADVANTAGES IN OOP: 1. Defining a Common Interface: Abstract classes set a blueprint for subclasses, ensuring they share common methods. 2. Organizing Code: They help group related classes under a common umbrella, improving code structure. 3. Extending Functionality: New features can be easily added by creating new subclasses of abstract classes. 4. Enhancing Maintainability: Abstract classes make code easier to understand and maintain by encapsulating related behavior. 16