#include<iostream.h>
#include<string.h>
class person
{
protected:
    char name[20];
    int code;
public:
    person(char *a,int c)
    {
        strcpy(name,a);
        code=c;
    }
    void dis()
    {
        cout<<endl<<"name : "<<name;
        cout<<endl<<"code : "<<code;
    }
};
class account:virtual public person
{
protected:
    long pay;
public:
    account(char *a,int b,long c):person(a,b)
    {
        pay=c;
    }
    void dis()
    {
        person::dis();
        cout<<endl<<"pay : "<<pay;
    }
};
class admin:virtual public person
{
protected:
    int experience;
public:
    admin(char *a,int b,int c):person(a,b)
    {
        experience=c;
    }
    void dis()
    {
        person::dis();
        cout<<endl<<"experience : "<<experience;
    }
};
class master:public account,public admin
{
public:
    master(char *a,int b,long c,int d):account(a,b,c),admin(a,b,d) { }/*[B][U] I am not able to figure it out how to pass the arguments to the ancestor class's constructor as both the intermediate base classes also pass value to the same. please help!!![/U][/B] */
    void dis()
    {
        person::dis();
        cout<<endl<<"pay : "<<pay;
        cout<<endl<<"experience : "<<experience;
    }
};
int main()
{
    master m("amit",1206,100,2);

    m.dis();
                cout<<endl;
    return 0;
}

your master class must explicitly initialize the person class, i think

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.