A
Q. Which class constructor is called in the following C++ code?
Code:
#include<iostream>
using namespace std;
class A {
public:
A()
{ cout << " The constructor of class A is called." << endl; }
};
class B {
public:
B()
{ cout << " The constructor of class B is called." << endl; }
};
class C: public A, public B {
public:
C()
{ cout << " The constructor of class C is called." << endl; }
};
int main()
{
C c;
return 0;
}
using namespace std;
class A {
public:
A()
{ cout << " The constructor of class A is called." << endl; }
};
class B {
public:
B()
{ cout << " The constructor of class B is called." << endl; }
};
class C: public A, public B {
public:
C()
{ cout << " The constructor of class C is called." << endl; }
};
int main()
{
C c;
return 0;
}
- Correct Answer - Option(C)
- Views: 30
- Filed under category C++
- Hashtags:
Discusssion
Login to discuss.