C언어 저축예금 클래스 VER.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){balance += money;}
void withdraw(int money){balance -= money;}
void print();
};
void BankAccount::print()
{cout << "예금주 : " << name << endl << "예금액 : " << balance << "원" << endl << "이율 : " << rate << "%" << endl;}
void main()
{
BankAccount ba("강봄");
ba.print();
}
#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){balance += money;}
void withdraw(int money){balance -= money;}
void print();
};
void BankAccount::print()
{cout << "예금주 : " << name << endl << "예금액 : " << balance << "원" << endl << "이율 : " << rate << "%" << endl;}
void main()
{
BankAccount ba("강봄");
ba.print();
}