Down below is the part of the main where pA is used. The error i'm getting is stack around pA was corrupted and i searched the net and didn't find an answer :( Can anyone help?
Is there something wrong with the while loop?
cout << "\nThat was just a test! Now for the real thing :)\nEnter a number of Teachers then a number of Students.\n";
Teacher* A;
Student* B;
int numb1, numb2;
cout << "\nHow many teachers do you want to add?\n";
cin >> numb1;
A = new Teacher[numb1];
cout << "\nEnter the teachers.\n";
for (int i = 0; i < numb1; i++)
{
cout << "\nEnter Name:\n";
cin >> name;
cout << "Enter Age:\n";
cin >> age;
cout << "Enter Salary:\n";
cin >> salary;
A[i].SetTeacher(name, age, salary);
}
cout << "\nHow many students do you want to add?\n";
cin >> numb2;
B = new Student[numb2];
cout << "\nEnter the students.\n";
for (int i = 0; i < numb2; i++)
{
cout << "\nEnter Name:\n";
cin >> name;
cout << "Enter Age:\n";
cin >> age;
cout << "Enter Grade:\n";
cin >> grade;
cout << "Enter Fees:\n";
cin >> fees;
B[i].SetStudent(name, age, grade, fees);
}
SortAName(A, numb1);
SortAName(B, numb2);
cout << "\nHere's an ordered list of the teachers:\n";
for (int i = 0; i < numb1; i++)
{
A[i].Print();
}
cout << "\nHere's an ordered list of the students:\n";
for (int i = 0; i < numb2; i++)
{
B[i].Print();
}
delete []A;
delete []B;
system("pause");
return 0;
}
template <class Type>
void SortAName(Type* A, int size)
{
for (int i = 0; i < size; i++)
{
for (int j = i + 1; j < size; j++)
{
if (A[i].GetName() > A[j].GetName()) Swap(A[i], A[j]);
}
}
}