이 소스코드에 대해서 설명좀 해주실분
남자
#include iostream
using namespace std;
class PermanentWorker{private: char name[100]; int salary;
public: PermanentWorker(char * name, int money) : salary(money) { strcpy(this-name, name); }
int GetPay() const { return salary; }
void ShowSalaryInfo() const { coutname: nameendl; coutsalary: GetPay()endlendl; }};
class EmployeeHandler{private: PermanentWorker * empList[50]; int empNum;
public: EmployeeHandler() : empNum(0) { }
void AddEmployee(PermanentWorker * emp) { empList[empNum++]=emp; }
void ShowAllSalaryInfo() const { for(int i=0;iempNum;i++) empList[i]-ShowSalaryInfo(); }
void ShowTotalSalary() const { int sum=0; for(int i=0;iempNum;i++) sum+=empList[i]-GetPay(); coutsalary sum: sumendl; }
~EmployeeHandler() { for(int i=0;iempNum;i++) delete empList[i]; }};
int main(void){ EmployeeHandler handler;
handler.AddEmployee(new PermanentWorker(KIM, 1000));/ * 1)여기에서 handler.AddEmployee(new PermanentWorker(LEE, 1500)); AddEmployee함수에게 handler.AddEmployee(new PermanentWorker(JUN, 2000)); 전달하는 인자는 무엇인가요? */
// 2) 클래스 PermanentWorker 내에 존재 하는PermanentWorker의 생성자를 동적으로 할당하는 건가요? // 3) 다른 클래스에서 동적으로 할당하여 접근하는것이 가능하였나요?
handler.ShowAllSalaryInfo();
handler.ShowTotalSalary();
return 0;}
-
글리슨
흐음... 조금만 기달려주세요..
-
Isolation
우와와와와 고마워요!
-
은솔
작은엔터님의 답변을 기다리는중