Answer to Question #234715 in C++ for SOM

Question #234715

Write the parameterized constructor for all the classes in the hierarchy.


class A

{ int a;}

Class B:public virtual A

{int b;}

Class C:public virtual A

{int c; }

Class D:public b,public C

{int d;}


1
Expert's answer
2021-09-10T18:54:33-0400
#include<iostream>
using namespace std;
class A
{
private:
 int a;
 public:
 	A(){
 		
	 }
	 //parameterized constructor
 A(int n){
 	a = n;
 }
 
 
};


class B: public virtual A
{
private:
int b;
public:
B(){
}
//parameterized constructor
B(int n){
	b= n;
}




};


class C:public virtual A
{
private:
int c; 
public:
C(){
}
//parameterized constructor
C(int n){
	c= n;
}


};


class D: public B ,public C
{
int d;
//parameterized constructor 
D(int n){
	d = n;
}


};
int main(){
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS