Computer Science, asked by danishauh8617, 18 days ago

A class has an integer data member 'i' and a function named 'printNum' to print the value of 'i'. Its subclass also has an integer data member 'j' and a function named 'printNum' to print the value of 'j'. Make an object of the subclass and use it to assign a value to 'i' and to 'j'. Now call the function 'printNum' by this object.

Answers

Answered by Anonymous
1

Answer:c

Explanation:

Answered by adityamishra3648
0

Answer:

code in c++

Explanation:

#include <iostream>

using namespace std;

class base

{

public:

   int i;

   void printnum()

   {

       cout << i << endl;

   }

};

class derived : public base

{

public:

   int j;

   void printnum()

   {

       cout << j << endl;

   }

   void setnum(int x, int y)

   {

       i = x;

       j = y;

   }

};

int main()

{

   derived d;

   d.setnum(4, 5);

   d.printnum();

   cout << d.i;

   return 0;

}

Similar questions