Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Abstraction and Abstract Class

1 topic ยท 28 Nov 2026
1

Abstraction and Abstract Class

OOP

Abstraction shows only the essential features and hides the details. Example: you press the brake without knowing how the brake system works.

In C++ a class with at least one pure virtual function (= 0) is an abstract class. It cannot be instantiated; child classes must implement the function.

C++
class Payment {                       // abstract class
public:
    virtual void pay(double amount) = 0;   // pure virtual
};

class Bkash : public Payment {
public:
    void pay(double amount) override { cout << "Paid " << amount << " by bKash\n"; }
};

// Payment p;       // error: cannot create an abstract object
Payment *p = new Bkash();
p->pay(500);