Q. For below code snippet, the public and protected members of Superclass becomes _________ members of Sub class.
class subclass : protected Superclass
Q. What will be the output of following code ?
#include <iostream>
using namespace std;
class Animal
{
public:
int legs = 4;
};
class Dog : public Animal
{
public:
int tail = 1;
};
int main()
{
Dog d;
cout << d.legs;
cout << d.tail;
}
Q. Do base class and its object have any knowledge about any classes derived from base class?
Q. What is Multiple Inheritance ?
Q. Whenever you create derived class object, first the base class default constructor is executed and then the derived class constructor?
Q. Which of the following Function is not inherited?
Q. What will be the output of following code?
#include <iostream>
using namespace std;
class Base
{
public:
Base() { cout << "Base"; }
};
class Derived : public Base
{
public:
Derived(int i) { cout << i; }
};
int main()
{
Derived d2(10);
return 0;
}
Q. What will be the output of following code?
#include <iostream>
using namespace std;
class A
{
int x;
};
class B : public A
{
public:
void show()
{
x=10;
cout << x;
}
};
int main()
{
B b;
b.show();
return 0;
}
Q. Which symbol is used to create multiple inheritance ?
Q. All members of a Base class including private member are inherited in Derived class.