-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass39.cpp
More file actions
41 lines (31 loc) · 857 Bytes
/
class39.cpp
File metadata and controls
41 lines (31 loc) · 857 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
35
36
37
38
39
40
41
#include <iostream>
using namespace std;
class book {
public:
string title;
int pages;};
class bankaccount {
private:
double balance;
public:
void deposit (double amount) {balance += amount;}
double get_balance() {
return balance;
}
};
int main() {
book my_book;
my_book.title = "tanseem";
my_book.pages = 310;
book b;
b.title = "1984";
b.pages = 500;
std::cout << "Book 1: " << my_book.title << ", Pages: " << my_book.pages << std::endl;
book* ptr= new book;
ptr->title = "Book";
ptr->pages = 200;
std::cout << "Book 2: " << b.title << ", Pages: " << b.pages << std::endl;
bankaccount acct;
acct.deposit(1000.0);
std::cout << "Account Balance: " << acct.get_balance() << std::endl;
}