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;}
#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(){
}
Comments
Leave a comment