You only have the following constructor:
payroll:payroll(float f)
This means that out of the following instantiations in your code:
payroll anil(1200),deepak(1300),acct;
only the first two are valid.
The first two are valid because of the constructor I quoted above has a
float
parameter.
You can either remove the last one:
payroll anil(1200), deepak(1300)
or add a default constructor:
class payroll
{
float salary;
public:
payroll()
{
salary=0.0f;
}
payroll(float f)
{
salary=f;
}
void show_salary()
{
cout<<"salary="<<salary;
}
payroll operator+(payroll);
};
NOTE: If you hadn't had any constructors the compiler would have added a default constructor, but since you have one it doesn't bother and you have to code it yourself.