- Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathclass of book.cpp
68 lines (58 loc) · 1.05 KB
/
class of book.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
usingnamespacestd;
classbook {
int pages;
int ISSN;
public:
//Special member function => Constructor
//No parameter constructor => Default Constructor
book() {
pages = 103;
ISSN = 4;
}
//Parameterised Constructor
book(int page, int issn) {
pages = page;
ISSN = issn;
}
voiddisplay() {
cout<<"pages: "<<pages<<endl;
cout<<"issn: "<<ISSN<<endl;
}
};
intmain() {
// your code goes here
book holy, sherlock(8, 500), madman;
holy.display();
sherlock.display();
madman.display();
return0;
}
/*#include <iostream>
using namespace std;
class book {
int pages;
int ISBN;
public:
//Default constructor
book() {
pages = 350;
ISBN = 1234;
}
//Parameterised constructor
book(int Pages, int isbn) {
pages = Pages;
ISBN = isbn;
}
void display() {
cout<<"Pages : "<<pages<<endl;
cout<<"ISBN : "<<ISBN<<endl;
}
};
int main() {
// your code goes here
book OOPS, OOPS1(300, 4567);
OOPS.display();
OOPS1.display();
return 0;
}*/