I have overloaded a function in a class called students.The one that input the info works but the one that outputs it does not work. I do believe the problem is somewhere in the main. The code was way worse, I have fixed a lot of problems and come to this. If I try to output the student's name, it just ends the program.
These are the member functions and variables:
class ShowStudents
{
public:
//Declaring a struct
struct Employee
{
string name_public = "";
int age_public = 0;
double ID_No_publice = 0;
};
//Array declaration of type Employee
Employee employees[arraysize];
void Students(int size_public)
{
cout << "Input the number of information to be entered: ";
cin >> size_public;
// Reseting the screen
system("cls");
for (int i = 0; i < size_public; i++)
{
cout << "Enter a name: ";
cin >> employees[i].name_public;
cout << endl;
cout << "Enter age: ";
cin >> employees[i].age_public;
cout << endl;
cout << "Enter the salary: ";
cin >> employees[i].salary_public;
cout << endl;
system("cls");
}
}
void Students(Employee employees[arraysize], int& size_public)
{
for (int i = 0; i < size_public; i++)
{
if (i == 0)
{
cout << setw(4) << "Name\t" << "Age\t" << "Wage" << endl << endl;
}
cout << setw(4) << employees[i].name_public << '\t'
<< employees[i].age_public << '\t'
<< employees[i].salary_public << endl;
}
}
};
> This is my main function:
int main()
{
//Declared the variables
student.Students(size);
student.Students(student.employees, size);<------ does not output
system("cls");
}
I have removed some parts of the main that are not that important. I wanted to provide a minimal reproducible code. I am using the Stack Overflow for a month so far, so if my question is bad or not understandable, you can tell me. I am also a month and a week into programming so I may ask a lot of questions that might be dumb. Please do not get mad.