Skip to content

Commit eb06cd1

Browse files
Added documentation
Added documentation for each function of the code
1 parent 1212c79 commit eb06cd1

8 files changed

+372
-12
lines changed

Class/Array-of-object-code.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
/**
2+
* @brief This program demonstrates the implementation of an array of objects in C++.
3+
*
4+
* The program defines a class `emp` to represent an employee with private attributes `id`, `name`, and `salary`.
5+
* The class provides public member functions `getdata` and `putdata` to set and display the employee data, respectively.
6+
*
7+
* In the `main` function, an array of `emp` objects `e1` is declared with a size of 23.
8+
* The user is prompted to enter the number of employee data to be stored.
9+
* Then, a loop is used to get and display the employee data using the `getdata` and `putdata` functions.
10+
*
11+
*/
12+
13+
// Program in C++ to implement array of object
14+
// Including Header Files
115
#include <iostream>
16+
17+
// Using namespace
218
using namespace std;
3-
//program to implement array of object
19+
20+
// Employee class
421
class emp
522
{
623
private:
724
int id;
25+
826
public:
927
string name;
1028
float salary;
@@ -22,6 +40,8 @@ class emp
2240
cout << "Salary is:" << salary << "" << endl;
2341
}
2442
};
43+
44+
// Main function
2545
int main()
2646
{
2747
emp e1[23];

Class/Book-class-code.cpp

+58-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
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
113
#include <iostream>
14+
15+
// Using Namespace
216
using namespace std;
17+
18+
/// @brief Class for book
319
class book
420
{
521
private:
622
int id;
23+
724
public:
825
string name;
926
string writer;
1027
string subject;
1128
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+
1245
void insert(int i, string n, string w, string s, string c)
1346
{
1447
id = i;
@@ -17,18 +50,39 @@ class book
1750
subject = s;
1851
course = c;
1952
}
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+
2062
void display()
2163
{
2264
cout << "Book details are:" << endl;
2365
cout << "Id is:" << id << "" << endl;
2466
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;
2968

69+
cout << "Subject is:" << subject << "" << endl;
70+
cout << "Course is:" << course << "" << endl;
3071
}
3172
};
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+
3286
int main()
3387
{
3488
book b1;

Class/Demo-class1.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,67 @@
1+
/**
2+
* @brief This file contains the implementation of a simple class 'demo' that demonstrates
3+
* the usage of input and output operations on private member variables.
4+
*
5+
* The 'demo' class has two private integer member variables 'a' and 'b'. It provides
6+
* two public member functions: 'input' to accept user input and store it in the private
7+
* member variables, and 'show' to display the values of the private member variables.
8+
*
9+
* The main function creates an instance of the 'demo' class, calls the 'input' and 'show'
10+
* methods, and then returns 0 to indicate successful program termination.
11+
*/
12+
13+
// Including Header File
114
#include <iostream>
15+
16+
// Using Namespace
217
using namespace std;
18+
19+
/// @brief Class for demo
320
class demo
421
{
522
private:
623
int a, b;
24+
725
public:
26+
/**
27+
* @brief This function is used to input two integer values into the class object.
28+
*
29+
* This function prompts the user to enter two integer values and stores them in the
30+
* private member variables 'a' and 'b' of the class.
31+
*
32+
* @return This function does not return any value.
33+
*/
34+
835
void input()
936
{
1037
cout << "Enter value: ";
1138
cin >> a >> b;
1239
}
40+
41+
/**
42+
* @brief This function is used to display the values of the private member variables 'a' and 'b'.
43+
*
44+
* This function outputs the values of the private member variables 'a' and 'b' to the standard output stream.
45+
* The values are separated by a tab character.
46+
*
47+
* @return This function does not return any value.
48+
*/
49+
1350
void show()
1451
{
1552
cout << a << "\t" << b;
1653
}
1754
};
55+
56+
/**
57+
* @brief The main function of the program.
58+
*
59+
* This function creates an instance of the 'demo' class, calls the 'input' and 'show' methods,
60+
* and then returns 0 to indicate successful program termination.
61+
*
62+
* @return 0 - Indicates successful program termination.
63+
*/
64+
1865
int main()
1966
{
2067
demo ob;

Class/Demo-class2.cpp

+47-1
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,68 @@
1+
/**
2+
* @brief This program demonstrates the usage of a simple student class with attributes for id and name.
3+
* The class includes methods to insert and display student information.
4+
*
5+
* @details The student class has two public attributes: id (integer) and name (string).
6+
* It includes two public methods: insert and display.
7+
* The insert method sets the id and name attributes of the student object.
8+
* The display method prints the id and name attributes of the student object to the console.
9+
* The main function creates two student objects, s1 and s2, and calls the insert and display methods on them.
10+
*/
11+
12+
// Including Header File
113
#include <iostream>
14+
15+
// Using Namespace
216
using namespace std;
17+
18+
/// @brief Class for student
319
class student
420
{
521
public:
622
int id;
723
string name;
24+
25+
/**
26+
* @brief Inserts values into the student object.
27+
*
28+
* This function sets the id and name attributes of the student object.
29+
*
30+
* @param i An integer representing the student's id.
31+
* @param n A string representing the student's name.
32+
*
33+
* @return void
34+
*/
35+
836
void insert(int i, string n)
937
{
1038
id = i;
1139
name = n;
1240
}
41+
42+
/**
43+
* @brief Displays the student's id and name.
44+
*
45+
* This function prints the id and name attributes of the student object to the console.
46+
*
47+
* @return void
48+
*/
49+
1350
void display()
1451
{
1552
cout << "Id is:" << id << "" << endl;
1653
cout << "Name is:" << name << "" << endl;
17-
1854
}
1955
};
56+
57+
/**
58+
* @brief The main function of the program.
59+
*
60+
* This function creates two student objects, s1 and s2, and calls the insert and display methods on them.
61+
*
62+
* @return An integer representing the exit status of the program.
63+
* - 0: The program executed successfully.
64+
*/
65+
2066
int main()
2167
{
2268
student s1;

Class/Employee-class-code.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,56 @@
1+
/**
2+
* @brief This program demonstrates the usage of a class to represent employee details.
3+
*
4+
* The emp class has private member variables for id, name, and salary. It provides public member functions
5+
* to insert and display employee details. The main function demonstrates the usage of the emp class by
6+
* creating two employee objects, prompting the user to enter employee details, inserting them into the
7+
* objects, and displaying the employee details.
8+
*/
9+
10+
// Including Header File
111
#include <iostream>
12+
13+
// Using Namespace
214
using namespace std;
15+
16+
/// @brief Class for employee
317
class emp
418
{
519
private:
620
int id;
21+
722
public:
823
string name;
924
float salary;
25+
26+
/**
27+
* @brief Inserts employee details into the object.
28+
*
29+
* This function takes three parameters: id, name, and salary. It assigns these values to the corresponding
30+
* member variables of the employee object.
31+
*
32+
* @param i An integer representing the employee's id.
33+
* @param n A string representing the employee's name.
34+
* @param s A float representing the employee's salary.
35+
*
36+
* @return void. This function does not return any value.
37+
*/
38+
1039
void insert(int i, string n, float s)
1140
{
1241
id = i;
1342
name = n;
1443
salary = s;
1544
}
45+
46+
/**
47+
* @brief Displays the employee details.
48+
*
49+
* This function prints the employee's id, name, and salary to the standard output stream.
50+
*
51+
* @return void. This function does not return any value.
52+
*/
53+
1654
void display()
1755
{
1856
cout << "Employee details are:" << endl;
@@ -21,6 +59,17 @@ class emp
2159
cout << "Salary is:" << salary << "" << endl;
2260
}
2361
};
62+
63+
/**
64+
* @brief The main function of the program.
65+
*
66+
* This function demonstrates the usage of the emp class by creating two employee objects, e1 and e2.
67+
* It prompts the user to enter employee details, inserts them into the objects using the insert function,
68+
* and then displays the employee details using the display function.
69+
*
70+
* @return An integer representing the exit status of the program. A return value of 0 indicates successful execution.
71+
*/
72+
2473
int main()
2574
{
2675
emp e1;

0 commit comments

Comments
 (0)