samedi 2 novembre 2019

In Case of Private Inheritance in C++ if we create dynamic object of Derived Class give Error

Error in code if i create dynamic object of derived class

#include<iostream>
using namespace std;
class Base
{
    public:
        Base()
        {
            cout<<"Base Class constructor"<<endl;
        }
        ~Base()
        {
            cout<<"Base Class Destructor";
        }
};
class Derived:Base
{
    public:
        Derived()
        {
            cout<<"Derived Class constructor"<<endl;
        }
        ~Derived()
        {
            cout<<"Derived Class Destructor";
        }
};
int main()
{
    Base *bptr=new Derived;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire