Inheritance And All Last Topic In C++ Date:- 06/09/2026

 // Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;


// class Parent{

//     public:

//     // void display(){

//     //     cout<<"Hello their!!"<<endl;

//     // }

//     virtual void display(){

//         cout<<"Hello their!!"<<endl;

//     }

// };


// class A:public Parent{};

// class B:public Parent{};

// class A:public Parent{};

// class B:public A{};

// class A{

//     public:

//     void dis(){

//         cout<<"Another display function"<<endl;

//     }

// };


// class B:public A,public Parent{};

// class B:public Parent{

//     public:

//     // void display(){

//     //     cout<<"Another version of display!!"<<endl;

//     // }

//     void display() override {

//         cout<<"Another version of display!!"<<endl;

//     }

// };


class Parent{

    public:

    virtual void dis(int a)=0;

};


class Cat:public Parent{

    public:

    void dis(int a) override{

        cout<<"Hello their "<<a<<endl;

    }

};



int main() {

    // Write C++ code here

    // Parent *a=new B();

    // a->display();

    // B a;

    // a.display();

    // Parent *a=new B();

    // a->display();

    // Parent a;

    Parent *a=new Cat();

    a->dis(12);


    try{

        // int a=10;

        // cout<<a/0<<endl;

        int a=0;

        if(a==0){

            // throw "Error";

            throw runtime_error("Error");

        }

    }

    // catch(const string a){

    // catch(const char* a){

    //     cout<<a<<endl;

    // }

    catch(...){

        cout<<"Error Occured"<<endl;

    }


    return 0;

}

Comments

Popular posts from this blog

Requests and Urllib

Strings in C Language

Dictionary in Python