class Account
{
int ID; //은행계좌
int L_Money; //남은돈 (Left Money)
char *Name; // 계주명
public:
Account(){}
Account(int ID, char *Name,int L_Money);
Account(const Account &Acc);
~Account();
void AddMoney(int L_M); // 입급
void SubMoney(int L_M); // 출금
int GetID() const; //계좌조회
int GetL_Money() const; // 잔액조회
const char *GetName() const;
void AllData();
};
Account::Account(int ID, char *Name, int L_Money)
{
this ->ID=ID;
this ->L_Money=L_Money;
this ->Name=new char[strlen(Name)+1];
strcpy(this->Name, Name);
}
Account::Account(const Account &Acc)
{
this ->ID=Acc.ID;
this ->L_Money=Acc.L_Money;
this ->Name=new char[strlen(Acc.Name)+1];
strcpy(this ->Name, Acc.Name);
}
Account::~Account()
{
delete []Name;
}
밑부터 블락 3개 있잔앙..
거기서
this -> ID=ID; 이게 무슨뜻이야??
또 Name 은 문자열이어서 저렇게 바꾸는건가..
이거 하는 이유좀 알려줘 ㅠㅠ;
맨 마지막에도
delete []Name
이것도 왜하는건지 모르겟엉 ㅠㅠ
this->ID = ID [현재의(this)객체의 ID라는 맴버변수에 인자로 들어온ID값을 넣겠다.
Name은 new로 문자열 길이+1(NULL)해서 동적할당후 memcpy로 문자열 복사..
delete []Name 동적할당된 name을 해제..