Sealed Class

Sealed class is a class that cannot be inherited by any class but can be instantiated. It is often used to encapsulate a logic that needs to be used across the program but without any alteration to it. In order to declare a sealed class we need to use final keyword after class name.

CODE

EG 1 . Creating a class called sampleClass and inheriting a sealed class Rectangle to it.

class Rectangle final {
  public:
    double length, width;
    double Area() {
        return length * width;
    }
}

class sampleClass : Rectangle {

}