C언어 저축예금 클래스 VER.1
너에게제공
432 0 0
#include <iostream>
#include <string>
using namespace std;
class BankAccount
{
private:
string name;
int balance;
int rate;
public:
BankAccount(string n){name = n; balance=1000; rate=5;}
void deposit(int money);
void withdraw(int money){balance -= money;}
void print();
};
void BankAccount::deposit(int money)
{
cout << "입금액 " << money<<endl;
balance = balance + money;
cout<< "잔고 " << balance<<endl;
}
void BankAccount::print()
{cout << "예금주 : " << name << endl << "예금액 : " << balance << "원" << endl << "이율 : " << rate << "%" << endl;}
void main()
{
BankAccount ba("강봄");
ba.print();
ba.deposit(5000);
}