1
+ /* *
2
+ * @file book.cpp
3
+ * @brief This program demonstrates the usage of a book class in C++.
4
+ *
5
+ * The book class has private member variables for id, name, writer, subject, and course.
6
+ * It provides public member functions to insert and display book details. The main function
7
+ * demonstrates the usage of the book class by creating two book objects, allowing the user
8
+ * to input details for each book, inserting the details into the book objects using the
9
+ * insert() function, and displaying the details using the display() function.
10
+ */
11
+
12
+ // Including Header File
1
13
#include < iostream>
14
+
15
+ // Using Namespace
2
16
using namespace std ;
17
+
18
+ // / @brief Class for book
3
19
class book
4
20
{
5
21
private:
6
22
int id;
23
+
7
24
public:
8
25
string name;
9
26
string writer;
10
27
string subject;
11
28
string course;
29
+
30
+ /* *
31
+ * @brief Inserts book details into the object.
32
+ *
33
+ * This function takes five parameters and assigns them to the corresponding
34
+ * member variables of the book object.
35
+ *
36
+ * @param i An integer representing the book's unique identifier.
37
+ * @param n A string representing the book's name.
38
+ * @param w A string representing the book's writer.
39
+ * @param s A string representing the book's subject.
40
+ * @param c A string representing the course the book is associated with.
41
+ *
42
+ * @return void This function does not return any value.
43
+ */
44
+
12
45
void insert (int i, string n, string w, string s, string c)
13
46
{
14
47
id = i;
@@ -17,18 +50,39 @@ class book
17
50
subject = s;
18
51
course = c;
19
52
}
53
+
54
+ /* *
55
+ * @brief Displays the book details.
56
+ *
57
+ * This function prints out the details of the book object, including its unique identifier, name, writer, subject, and course.
58
+ *
59
+ * @return void This function does not return any value.
60
+ */
61
+
20
62
void display ()
21
63
{
22
64
cout << " Book details are:" << endl;
23
65
cout << " Id is:" << id << " " << endl;
24
66
cout << " Name is:" << name << " " << endl;
25
- cout << " writer is:" << writer << " " << endl;
26
-
27
- cout << " subject is:" << subject << " " << endl;
28
- cout << " course is:" << course << " " << endl;
67
+ cout << " Writer is:" << writer << " " << endl;
29
68
69
+ cout << " Subject is:" << subject << " " << endl;
70
+ cout << " Course is:" << course << " " << endl;
30
71
}
31
72
};
73
+
74
+ /* *
75
+ * @brief The main function of the program.
76
+ *
77
+ * This function demonstrates the usage of the book class by creating two book objects,
78
+ * b1 and b2, and allowing the user to input details for each book. The details are then
79
+ * inserted into the book objects using the insert() function, and displayed using the
80
+ * display() function.
81
+ *
82
+ * @return An integer representing the exit status of the program. A return value of 0
83
+ * indicates that the program executed successfully.
84
+ */
85
+
32
86
int main ()
33
87
{
34
88
book b1;
0 commit comments