반응형
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
namespace COMP_POS {
enum
{
CLERK = 1,
SENIOR = 2,
ASSIST = 3,
MANAGER = 4
};
void ShowPositionInfo(int pos)
{
switch (pos)
{
case CLERK:
cout << "사원" << endl;
break;
case SENIOR:
cout << "주임" << endl;
break;
case ASSIST:
cout << "대리" << endl;
break;
case MANAGER:
cout << "과장" << endl;
break;
}
}
}
class NameCard {
private:
char* name;
char* comp;
char* pnum;
int rank;
public:
NameCard(char* myname, char* mycomp, char* mypnum, int pos) :name(myname), comp(mycomp), pnum(mypnum), rank(pos)
{
int len = strlen(myname)+1;
name = new char[len];
strcpy(name, myname);
int len2 = strlen(mycomp)+1;
comp = new char[len2];
strcpy(comp, mycomp);
int len3 = strlen(mypnum)+1;
pnum = new char[len3];
strcpy(pnum, mypnum);
rank = pos;
}
void ShowNameCardInfo() const
{
cout << "이름: " << name << endl;
cout << "회사: " << comp << endl;
cout << "전화번호: " << pnum << endl;
cout << "직급: "; COMP_POS::ShowPositionInfo(rank);
}
~NameCard()
{
delete[]name;
delete[]comp;
delete[]pnum;
}
};
int main()
{
char cle[4] = "Lee";
char sen[5] = "Hong";
char ass[4] = "Kim";
char cle2[] = "ABCEng";
char sen2[] = "OrangeEng";
char ass2[] = "SoGoodComp";
char cle3[] = "010-1111-2222";
char sen3[] = "010-3333-4444";
char ass3[] = "010-5555-6666";
NameCard manClerk(cle, cle2, cle3, COMP_POS::CLERK);
NameCard manSENIOR(sen, sen2, sen3, COMP_POS::SENIOR);
NameCard manAssist(ass, ass2, ass3, COMP_POS::ASSIST);
manClerk.ShowNameCardInfo();
manSENIOR.ShowNameCardInfo();
manAssist.ShowNameCardInfo();
return 0;
}
반응형
'Programming > C++' 카테고리의 다른 글
열혈c++ 문제 4-1 , 4-2 (0) | 2021.08.15 |
---|---|
열혈c++ Chapter 04 문제04-3 (0) | 2021.08.15 |
c++ winmain (0) | 2021.08.15 |
모던 c++ 챌린지 3이나 5로 나누어떨어지는 자연수의 합 , 최대공약수, 최소공배수 (0) | 2021.08.15 |
모던 c++ 챌린지 주어진 수보다 작은 가장큰 소수 예제 (0) | 2021.08.15 |