-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoopm05.cpp
More file actions
34 lines (34 loc) · 704 Bytes
/
oopm05.cpp
File metadata and controls
34 lines (34 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream>
#include<string>
using namespace std;
class bankAccount{
int accno,balance=0;
string name;
public:
bankAccount(string n,int a){
name=n;
accno=a;
}
void deposit(int amount){
balance+=amount;
}
void withdraw(int amount){
if(balance<amount){
cout<<"insufficient balance"<<endl;
}
else{
balance-=amount;
}
}
void display(){
cout<<"name is "<<name<<endl;
cout<<"account number is "<<accno<<endl;
cout<<"balance is "<<balance<<endl;
}
};
int main(){
bankAccount b("tanya",12345);
b.deposit(500);
b.withdraw(600);
b.display();
}