-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion4.cpp
71 lines (58 loc) · 1.66 KB
/
question4.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
69
70
#include <iostream>
#include <string>
class liberatyItems{
protected:
std::string title;
std::string author;
public:
liberatyItems(std::string title = " ", std::string author =" "){
this->title= title;
this->author = author;
}
void getTitle(){
std::cout << "The title of the book is:: " << title;
}
void display(){
std::cout << "The title is:: " << title << std::endl;
std::cout << "The author is:: " << author << std::endl;
}
std::string getAuthor(){
return author;
}
};
class Book : public liberatyItems{
protected:
int noofPages;
public:
Book(std::string title = " ", std::string author= " ", int noofPages = 0):liberatyItems(title, author)
{
this->noofPages = noofPages;
}
void display(){
std::cout << "\nTitle:: " << title;
std::cout << "\nAuthor:: " << author;
std::cout << "\nNo of Pages:: " << noofPages << std::endl;
}
};
class magazine : public liberatyItems{
protected:
int issueNumber;
public:
magazine(std::string title = " ", std::string author = " ", int issueNumber= 0):liberatyItems(title,author ){
this->issueNumber = issueNumber;
}
void display(){
std::cout << "\nTitle:: " << title;
std::cout << "\nAuthor:: " << author;
std::cout << "\nThe issue number of the magazine is :: " << issueNumber << std::endl;
}
};
int main(){
Book b1("The rich dad and a poor dad" , "Robert kiwosakki" ,234);
Book b1("The rich dad and a poor dad" , "Abert kiwosakki" ,234);
b1.display();
liberatyItems l("Saksham" ,"Humagain");
l.display();
magazine m("HotNews", "Kantipur " ,45);
m.display();
}