See c++ structure arrangement

Asked 2 years ago, Updated 2 years ago, 54 views

void CalcGPA(Subject& Sub);
structure subject {// subject information
    charSubName[30]; // Subject Name
    int Hakjum; // Subject credit
    Char Grade[10]; // Subject Grade
    float GPA; // subject rating
};
structure Student {// Student Information
    charStdName[30]; // Student Name
    int Hakbun; // Class number
    Subject Sub[3]; // Subject
    float AveGPA; // Subject Average Rating
};
int main(){
Subject subject[6];
    Student student[2];
for (int i = 0; i < 3; i++)
            {
                cout << "Lecture name:";
                cin >> subject[i].SubName;
                cout << "Subject credit score :");
                cin >> subject[i].Hakjum;
                cout << "Subject grade<A+~F>: ";
                cin >> subject[i].Grade;
                cout << "\n";
                CalcGPA(subject[i].Grade);
            }
    }
subject[i] within this code.An error occurs when I try to refer to the grade using the structural reference. What should I do? You have entered only the code for the part you think is necessary for the question.

c++ reference

2022-09-21 11:15

1 Answers

void CalcGPA(Subject& Sub);

Looking at the declaration part of the function, it is referenced by the subject structure CalcGPA(subject[i].Grade); is inserting a character array.


2022-09-21 11:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.