Question

In: Computer Science

Fill in the blanks with suitable code and identify the type of inheritance in the following...

Fill in the blanks with suitable code and identify the type of inheritance in the following code
snippet.(CO5) [Write all the three constructors completely in the answer sheet. Don’t write any
other parts of the program]
class Xyz
{
int one, two;
public:
Xyz(--------)
{one=i;
--------;
}
};
class Abc
{
int dc;
public:
Abc(int k)
{-----------;}
};
class Ijk: public Abc, public Xyz
{
int f;
public:
Ijk(int l, int m, int z, int n):-------,---------
{ f=n;}
};
int main()
{ Ijk T1(2,6,3,8); }

Solutions

Expert Solution

Class ABC()
{
   public:
       int a;
       ABC()
       {      
           a=1;
       }
}
Class XYZ()
{
   public:
       int b;
       ABC()
       {      
           b=2;
       }
}
Class pqr(): public ABC, public XYZ
{
   public:
       int c;
       pqr()
       {  
           c=0  
           c=a+b;
       }
}

This type of inheritance is called multiple inheritances. The class inherits from more than one class. We should call constructors in the same order in which they are created.
Constructors are called automatically when the object is created.
There are three constructors in the question ABC, XYZ, and a child class pqr.
For accessing the constructor of the parent class using the scope resolution operator(':').

#include<bits/stdc++.h>
using namespace std;

class Xyz
{
        int one, two;
        public:
                //creating parametrized constructor
                Xyz(int i, int j)
                {       
                        one = i;
                        two = j;
                }
};
class Abc
{
        int dc;
        public:
                Abc(int k)
                {
                        dc = k;
                }
                
};
class Ijk: public Abc, public Xyz
{
        int f;
        public:
        Ijk(int l, int m, int z, int n): Xyz(l, m), Abc(z)
        { 
                f = n;
        }
};
int main()
{
        Ijk T1(2,6,3,8); 
}

Related Solutions

Fill in the blanks in the MATLAB code below.
Fill in the blanks in the MATLAB code below. (Do not type unnecessary words or blank spaces in your response. The correct answers are case-sensitive.) % Consider a row vector v. % Complete the lines of code below to find the average and standard deviation of the elements of vector v such that these two values are assigned to variables M and S, respectively. E = G =
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that...
The following code fragment is expressed in arm assembly code. Fill in the blanks, so that it is equivalent to the following C code. int counter; int x = 5; int y = 6; for (counter =10; counter >0;counter--) IF(X==Y) Y = Y + 1 ; ELSE Y = Y + 2} Fill in the blanks in the following code: MOV__________ ;loop counter into r0-ten times round the loop MOV__________ ;Value of y loaded into r1 MOV__________ ;Value of x...
Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase...
Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase or decrease. I2(s) + 5F2(g) ⇌ 2IF5(g) A decrease in volume results in a Blank 1 in pressure which will Blank 2 the amount of IF5.
Part 1 Fill in the blanks in the five sentences given below with the most suitable...
Part 1 Fill in the blanks in the five sentences given below with the most suitable words:    (Inventory - revenue - reconciliation – appraisal – goodwill) (a) In business, ………… is the income that a company receives from its normal business activities, usually from the sale of goods and services to customers. (b) ………… is an intangible, sale able asset arising from the reputation of a business and its relations with its customers. (c) Matching of the cash balance shown...
Fill in the blanks on the following table
 Fill in the blanks on the following tableE&pshareholder basisdistributiondividendreturn of capitalcapital gain20,000300,00080,000120,00010,000170,000220,000100,000170,00020,000080,000<20,000>50,000170,000
Fill-In-The-Blanks 13. Complete the code by filling in the blanks for each question below. (Length of...
Fill-In-The-Blanks 13. Complete the code by filling in the blanks for each question below. (Length of blank doesn’t matter.) a) Print out the contents of the array airlines. #include #include ________________ using namespace std; int main () { string airlines[] = {"american","pan-am","southwest"}; for (int i = 0;_______________;i++) cout << ____________ << endl; return 0; } b) Read in 5 integers from the user and write them back out in reverse order int numbers[5]; for(int i = 0; ___________; _________) cin...
Fill in the blanks of the following segment of code, so that the output would be 1 3 4.
Fill in the blanks of the following segment of code, so that the output would be 1 3 4.int count = 0;do{++ count;if (count == 2)Blank;cout << count << " ";} while (count <= Blank);cout << endl;
Fill in the blanks in each of the following statements
Fill in the blanks in each of the following statementsa) --------- allows you to build JavaFx GUIS using drag and drop techniques.b) The elements in the scene graph are called --------------c) A(n) ----------- file contains the description of a JavaFX GUI.d) The method ---------------- is called by FMXLLoader before the GUI is displayed
Fill in the blanks with an appropriate suggestion for the following.
Fill in the blanks with an appropriate suggestion for the following.(i) If there is no trade-off involved when we get a good, then it is called a _______________ good.(ii) If expected future price falls for a good, it's current demand _____________________ .(iii) Pencil and erasers are a pair of ___________________goods for consumers
Fill in the blanks to complete the following table.
Fill in the blanks to complete the following table.SymbolIon FormedNumber of Electrons in IonNumber of Protons in IonF__________9Te_____54_____II−_______________Mg2+_____12Part AComplete the first column of the table.Express your answer as a chemical symbol.Part BComplete the second column of the table.Express your answer as ions. Enter your answers in order given in the table, from top to bottom, separated by a comma.Part CComplete the third column of the table.Express your answer as integers. Enter your answers in order given in the table, from...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT