this program is simply for recording data of various staffs.Inheritance has been used for taking additional data.Staff is the base class.the classes officer,typist and teacher are the derived classes.again the classes regular and casual are derived from the class typist.
now my problem is that whenever i call the constructor functions of respective classes,it gives an error saying no match to function call.can anyone help me with this. i dont get why the call doesnt match as all the arugments match....???
#include<iostream>
#include<string.h>
using namespace std;
class staff{
protected:
char name_main[];
int code;
public:
staff(){}
staff(char n[],int c)
{
code=c;
strcpy(name_main,n);
}
};
class teacher:public staff
{
char subject[30],publication[30];
public:
teacher(){}
teacher(char name[],int c,char subj[],char pub[]):staff(name,c)
{
strcpy(subject,subj);
strcpy(publication,pub);
}
};
class officer:public staff
{
char grade[2];
public:
officer(){}
officer(char name[],int c,char g[]):staff(name,c)
{
strcpy(grade,g);
}
};
class typist:public staff
{
protected:
int speed;
public:
typist(){}
typist(char name[],int c,int s):staff(name,c)
{
speed=s;
}
};
class regular:public typist
{
public:
regular(){}
regular(char name[],int c,int s):typist(name,c,s){}
};
class casual:public typist
{
protected:
int daily_wages;
public:
casual(){}
casual(char name[],int c,int s,int wage):typist(name,c,s)
{
daily_wages=wage;
}
};
int main()
{
int choice,choice2,option,n;
int code,speed,wage;
char name[30],sub[20],pub[30],grad[2];
do
{
cout<<"choose any one among the following options:\n";
cout<<"1.teacher\n2.typist\n3.officer\n\t\t";
cin>>choice;
if(choice==1)
{
cout<<"enter no of entries:";
cin>>n;
teacher t[n];
for(int i=0;i<n;i++)
{
cout<<"enter name and code:";
cin>>name>>code;
cout<<"enter the subject and the publication:";
cin>>sub>>pub;
t[i](name,code,sub,pub);
}
}
else if(choice==2)
{
cout<<"enter 1 for regular and 2 for casual:";
cin>>choice2;
if(choice2==1)
{
cout<<"enter the no of entries";
cin>>n;
typist reg[n];
for(int i=0;i<n;i++)
{
cout<<"enter name and code:";
cin>>name>>code;
cout<<"enter the speed of typist(word per minute):";
cin>>speed;
reg[i](name,code,speed);
}
}
else
{
cout<<"enter the no of entries";
cin>>n;
typist cas[n];
for(int i=0;i<n;i++)
{
cout<<"enter name and code:";
cin>>name>>code;
cout<<"enter the speed of typist(word per minute):";
cin>>speed;
cout<<"enter the daily wage:";
cin>>wage;
cas[i](name,code,speed,wage);
}
}
}
else
{
cout<<"enter the no of entries";
cin>>n;
officer o[n];
for(int i=0;i<n;i++)
{
cout<<"enter name and code:";
cin>>name>>code;
cout<<"enter the grade";
cin>>grad;
o[i](name,code,grad);
}
}
cout<<"enter 0 for exit and any number for adding another data:";
cin>>option;
}while(option!=0);
}
the error is no match to function calls.