OOPS
August 29, 2024
OOPS
August 29, 2024
OOPS
August 29, 2024
OOPS
August 29, 2024

OOPS

Question 147
Give the output
#include
using namespace std;
class Base
{
Public:
int x,y;
Public:
Base(int i, int j)
{
x=i;y=j;
}
};
class Derived:public Base
{
public:
Derived(int i,int j):x(i),y(j){}
void print()
{
cout<<x<<""<<y;
};
int main(void)
{
Derived q(10,10);
q.print();
return 0;
}
</x<<""<<y;
A
1010
B
compile error
C
00
D
None of the option
Question 147 Explanation: 
We can’t directly assign the base class members by using​ ​ initializer list​ in the derived class
We should call the base class constructor in order to initialize base class members.
Correct Answer: B
Question 147 Explanation: 
We can’t directly assign the base class members by using​ ​ initializer list​ in the derived class
We should call the base class constructor in order to initialize base class members.

Leave a Reply

Your email address will not be published. Required fields are marked *