Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

This is the beginning of our program, and it includes three standard libraries the `<iostream>`,

`<iomanip>`, and `<vector>`.

First is include \<iostream\>


- This line includes the input/output stream library in C++. It provides functionality for basic input
and output operations. The `<iostream>` library is commonly used for tasks such as reading from and
writing to the console.

2nd is #include \<iomanip\>**


- This line includes the input/output manipulator library . this library is used for setting various
formatting options for input and output operations. It allows us to control the alignment, precision,
and other formatting aspects.

3rd is #include \<vector\>**


- This line includes the Standard Template Library (STL) header for vectors. This library provides a
dynamic array-like data structure called a vector. Vectors are useful for storing and manipulating
sequences of elements, and they automatically handle memory allocation and deallocation.

Next is using namespace std


- This line is a convenience statement that brings the entire `std` (standard) namespace into the
current scope. This contains the standard library components. So By using this statement, you can
avoid typing `std double colon` before standard library elements, this making the code more concise.

these components collectively empower our C++ program to communicate with users, format output
neatly, manage dynamic arrays efficiently, and maintain code clarity.

In this part of our program code


The class keyword is used to define a class in. In our program, it is named ElementaryStudent.

As you can see here there is a word public called acsess modifier, this access modifier specifies that
the members declared after it are accessible from outside the class. It means that other parts of the
program can access and modify these variables.

These are the member variables that store information about the elementary student, Parent
Information, and Additional information for returning/transferee status.

int is used for integer (whole number) data types that’s why we use int in schoolYear, age, house
number, zip code , psaBirthCertificateNumber, learnerReferenceNumber, and contact number
variables .Then string is used for storing sequences of characters or numbers, that’s why we used
string function in Last name
First name
Middle name
Birthdate
Sex
Place of birth
Religion
Citizenship
Sitio/Street Name
Barangay
Municipality
Province and ;
Country variables

In Here, a nested struct named Parent is defined to store information about a student's parents.
father and mother are instances of the Parent struct, representing the student's father and mother,
respectively.

- This line declares the constructor for the `ElementaryStudent` class. The constructor has the same
name as the class and is called when an object of the class is instantiated.

This constructor is responsible for initializing the member variables of an object of the
ElementaryStudent class with default values.

- This colon `:` starts the member initialization list. It initializes the member variables of the class
with specific values.
- Each member variable is followed by a value in parentheses, indicating the default value for that
variable.
- The semicolon at the end (`};`), marks the end of the class definition and the constructor
implementation.
- Semicolons are used to terminate statements or declarations.
- the Quotation marks are used to represent an empty string.
- The open curly bracket, `{` marks the beginning of the constructor body, and the closing curly
bracket , `}` marks its end. Everything between these braces constitutes the constructor
implementation.
Then - Parentheses are used to enclose the values provided for initializing the member variables.

- `class ElementaryEnrollmentSystem`: This line declares a class , named


`ElementaryEnrollmentSystem`. It serves as a blueprint for creating objects related to an
elementary school enrollment system.

As you can see here there is a word private this is a type of access modifier, this is used to designate
members (variables and functions) that are only accessible within the class itself. Anything declared as
private cannot be accessed directly by code outside the class.

1. `vector<ElementaryStudent> elementaryStudents;`: This vector is intended to store enrolled


elementary students. Making it private ensures that only member functions of the class can directly
manipulate or access this vector. This encapsulation helps control how the class's internal data is
modified or accessed, preventing external code from directly modifying the vector.

2. `void displaySubjects(const string& grade, double& totalCost);`: This function seems to be


responsible for displaying subjects and calculating the total cost based on the grade. It is marked as
private, because it can only be called within the class. This suggests that this functionality is meant to
be used internally by the class, and external code should not be able to call this function directly.

3. `void displaySections();`: This function is designed to display available sections. It is marked as


private, indicating that it should only be used internally within the class. External code should not
have direct access to this functionality.

4. `string getSection();`: This function is used to get the selected section from the user. Marking it as
private ensures that only the class's member functions can call this function, controlling how the
section information is obtained.
By making these members private, the class is enforcing encapsulation, which helps maintain the
integrity of its internal state and provides a clear interface for external code to interact with the class.
External code can use public member functions to interact with the class while the internal
implementation details, like the enrolled students vector and certain display functions, are hidden.

public:
void enrollElementaryStudent();
void displayEnrolledStudents();
```
-there Two public member functions are declared: `enrollElementaryStudent` and
`displayEnrolledStudents`. These functions are accessible from outside the class that’s why it is
under the public access modifier.
- `enrollElementaryStudent`: Represents a function to enroll an elementary student.
- `displayEnrolledStudents`: Represents a function to display information about enrolled students.

You might also like