Z
zfareed
This is my program using a struct and an array and an attempt to pass
the array to a function. What does this compilation error mean?
#include <iostream>
#include <iomanip>
using namespace std;
struct Employee
{
int age;
int id;
float salary;
};
void PrintEmployee(Employee,int);
int main()
{ Employee employee[2];
employee[0].age = 30;
employee[0].id = 30042554;
employee[0].salary = 5000.00;
employee[1].age = 45;
employee[1].id = 40041002;
employee[1].salary = 70000.00;
PrintEmployee(employee,2);
system("pause");
return 0;
}
void PrintEmployee(Employee employee[],int length)
{
cout << "EmployeeID " << " Age " << " " << " Salary "
<< endl;
cout << "------------------------------" << endl;
cout << endl;
for(int i=0;i< length;i++)
{
cout << employee.id << " " ;
cout << employee.age<< " " ;
cout << setw(8) << fixed << setprecision(2) <<
employee.salary<< " " << endl;
}
}
\My Documents\C++\projects\lab4.cpp conversion from `Employee*' to non-
scalar type `Employee' requested
the array to a function. What does this compilation error mean?
#include <iostream>
#include <iomanip>
using namespace std;
struct Employee
{
int age;
int id;
float salary;
};
void PrintEmployee(Employee,int);
int main()
{ Employee employee[2];
employee[0].age = 30;
employee[0].id = 30042554;
employee[0].salary = 5000.00;
employee[1].age = 45;
employee[1].id = 40041002;
employee[1].salary = 70000.00;
PrintEmployee(employee,2);
system("pause");
return 0;
}
void PrintEmployee(Employee employee[],int length)
{
cout << "EmployeeID " << " Age " << " " << " Salary "
<< endl;
cout << "------------------------------" << endl;
cout << endl;
for(int i=0;i< length;i++)
{
cout << employee.id << " " ;
cout << employee.age<< " " ;
cout << setw(8) << fixed << setprecision(2) <<
employee.salary<< " " << endl;
}
}
\My Documents\C++\projects\lab4.cpp conversion from `Employee*' to non-
scalar type `Employee' requested