Hi, how you all doing? I currently enroll C++ programming class in some community college, this is my second C++ class. I still have many thing to learn about it.
I am now facing with some class assignment problem that I couldn't go any further, would you guys please help me out here?
It gives me some ERRORs:
-expected constant expression
-cannot allocate an array of constant size 0
-'emp' : unknown size
Here is my program:
Code:
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
//STRUCTURE AND UNION//////////////////////////////////////////////////////////////////////
union payRate
{
long salary;
float hour;
int commission;
};
struct Employee
{
char ID[4];
char name[36];
char payStatus[20];
float grossPay;
};
////////////////////////////////////////////////////////////////////////////////////////////
//FUNCTIONS/////////////////////////////////////////////////////////////////////////////////
int getEmployeeData(Employee*, int);
////////////////////////////////////////////////////////////////////////////////////////////
//MAIN (STARTING POINT)/////////////////////////////////////////////////////////////////////
int main()
{
int numEmployee;
Employee emp[numEmployee];
cout<<"Enter maximum number of employees to enter: ";
cin>>numEmployee;
getEmployeeData(emp, numEmployee);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////
//ALL THE FUNCTION DEFINITIONS//////////////////////////////////////////////////////////////
int getEmployeeData(Employee* e, int numEmployee2)
{
for(int loop=0; loop<numEmployee2; e++)
{
cout<<"Enter employee id (Enter to quit): ";
cin.ignore();
cin.getline(e->ID,4);
cout<<"Enter name (Last, First): ";
cin.ignore();
cin.getline(e->name,36);
cout<<"Enter payroll status: ";
cin.ignore();
cin.getline(e->payStatus,20);
}
return 0;
}
Thank you very much
JJ