21.3 ACCOUNT AND FINANCE
21.3.1 Bank account
Problem: Define a class to represent bank account. Include the following members:
Data members:
- Name of depositor.
- Account number.
- Type and account.
- Balance amount in the account.
Member functions:
- To assign initial values.
- To deposit an amount.
- To withdraw an amount after checking the balance.
- To display name and balance.
Write a main function to test the program.
Solution: See Program 21.6.
Program 21.6 Bank account
// bank3.cpp
#include<iostream.h>
#include<string.h>
class BankAccount
{ protected :
char name[20] ;
int accNumber ;
int bal ;
public:
BankAccount(char *p,int i,int j) ;
void deposit(int sum);
int withdraw(int sum) ;
void display();
};
int main() ...
Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.