What is the output of the program?
#include <iostream>
using namespace std;
class Base1 {
public:
~Base1() { cout << " Base1's destructor" << endl; }
};
class Base2 {
public:
~Base2() { cout << " Base2's destructor" << endl; }
};
class Derived: public Base1, public Base2 {
public:
~Derived() { cout << " Derived's destructor" << endl; }
};
int main()
{
Derived d;
return 0;
}
1 Crore+ students have signed up on EduRev. Have you? Download the App |
How many types of inheritance are there in c++?
How many types of constructor are there in C++?
What is the output of the program?
#include<iostream>
using namespace std;
class Base {};
class Derived: public Base {};
int main()
{
Base *bp = new Derived;
Derived *dp = new Base;
}
What is the output of the program?
#include<iostream>
using namespace std;
class Base
{
public:
int fun() { cout << "Base::fun() called"; }
int fun(int i) { cout << "Base::fun(int i) called"; }
};
class Derived: public Base
{
public:
int fun() { cout << "Derived::fun() called"; }
};
int main()
{
Derived d;
d.fun(5);
return 0;
}
Output of following program?
#include <iostream>
#include<string>
using namespace std;
class Base
{
public:
virtual string print() const
{
return "This is Base class";
}
};
class Derived : public Base
{
public:
virtual string print() const
{
return "This is Derived class";
}
};
void describe(Base p)
{
cout << p.print() << endl;
}
int main()
{
Base b;
Derived d;
describe(b);
describe(d);
return 0;
}
73 videos|7 docs|23 tests
|