我正在構建員工數據的程序,出於某種原因,我的代碼無法運行,我搜索了此論壇和其他人,並且我無法弄清楚我的代碼存在問題。運行失敗(退出值1)C++
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
class Employee{
public:
int idNumber;
float SalaryRate;
char * name;
int BaseSalary;
char * hisname;
float salary;
float bonus;
float finalSalary;
Employee(int idNum) //default constructor function
{
SalaryRate=0;
BaseSalary=0;
idNumber=idNum;
BaseSalary=0;
salary=0;
bonus=0;
}
//constructor function with parameters
Employee(char * name, int SalaryRate, int idNumber)
{
SalaryRate=0;
idNumber=0;
strcpy(name, hisname) ;
}
float setBonus()
{
cout<<"What is the bonus for this employee?\n";
cin>>bonus;
}
void increaseSalary (float increase)
{
cout<<"By what percentage would you like to increase ";
cout<<"p";
cout<<"'s salary? \n";
cin>>increase;
finalSalary = salary * (increase/100)+bonus;
}
void print()
{
cout<<"the salary of ";
cout<<* name;
cout<< " is ";
cout<<finalSalary;
}
};
int main() {
Employee * employees[100];
for(int i = 0; i < 100; i++)
{
cout<<"What is the name you would like to input? ";
cin>>employees[i]->name;
int idNumber=i;
cout<<"What is "; employees[i]->name; "'s hourly rate? ";
cin>>employees[i]->SalaryRate;
}
//Employee a();
//a.increaseSalary();
return 0;
}
你有什麼樣的問題?如果你不能編譯它,什麼錯誤消息給編譯器? –