Technote/Data Structure C++ [C++] 함수가 존재하는 구조체의 변수 Pooh0216 2009. 9. 18. 00:06 반응형 #include<iostream> using std::cout; using std::endl; struct Account{ char accID[20]; char secID[20]; char name[20]; int balance; void Deposit(int money){ balance+=money; } void Withdraw(int money){ balance-=money; } }; int main(void) { Account yoon={"1234","2321","yoon",1000}; yoon.Deposit(100); cout<<"잔 액 : "<<yoon.balance<<endl; yoon.Withdraw(200); cout<<"잔 액 : "<<yoon.balance<<endl; return 0; } 반응형 저작자표시 (새창열림)