Showing posts with label hybrid constructor. Show all posts
Showing posts with label hybrid constructor. Show all posts

Sunday, May 8, 2022

program to show hybrid constructor order and in general inheritence constructor order

 #include <iostream>

using namespace std;
class A
{
    int num1;
public:
    A() { cout << "hi from A\n"; }
    A(int num1){
        this-> num1=num1;
        cout<<num1<<endl;
    }
};
class B : virtual public A
{
    int num2,  num3;
public:
B(int num2,int num3){
    this->num2=num2;
    this->num3=num3;
    cout<<num2<<endl;
    cout<<num3<<endl;
}
    B() { cout << "hi from B\n"; }

};
class C : virtual public A
{
    int num4;
public:
    C() { cout << "hi from C\n"; }
    C(int num4){
        this->num4=num4;
        cout<<num4<<endl;
    }
};
class D : public B, public C
{int num5 ;
string name;
public:
    D() { cout << "hi from D\n"; }
    D(int num5,string name,int n1,int n2, int n3,int n4):A(n2),B(n1,n4),C(n2){
        this->num5=num5;
        this->name=name;
        cout<<num5<<endl<<name<<endl;
    }
};
int main()
{
    D b, d(1,"nitin",13,12,15,10);
    return 0;
}

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts