I'm having trouble how to figure out this problem I'm assigned. When I'm referencing the code I keep getting a message saying "no matching function for call to 'getStudentInfo'.
//Here's what I'm supposed to do
Objectives:
Structured Data: struct, array of struct, and nested struct
Assignment: Write a C++ program to record and display a list of student records.
1. Define a structure to hold the following information of a Student:
char name[NAME_SIZE];
char id[ID_SIZE];
int years;
double gpa;
Course courses[COURSE_SIZE];
2. Define a structure to hold the following information for a Course
char cName[CNAME_SIZE];
int cNum;
char days[DAYS];
char instructor[NAME_SIZE];
3. Define a array variable students to hold students’ records
4. getStudentInfo(Student [ ], int&) This function asks user to input data for student name, id, years, gpa,
and the courses he/she is taking this semester.
5. getCourses(Course [ ], int &) This function is called by getStudentInfo to get the information of the
courses for a student.
6. displayStudents(Student [ ], int) This function displays the students information
Sample output:
Student Name: John Smith
Student ID: 000123456
Year in school: 2
GPA: 4.0
Course Name: CSI
Course Number: 1470
Schedule: MWF
Instructor: Wei
More courses? y
Course Name: DataStructure
Course Number: 2320
Schedule: TH
Instructor: Jim
More courses? n
More students? y
Student Name: Peter Pan
Student ID: 000234567
Year in school: 10
GPA: 1.0
Course Name: HowToFly
Course Number: 1000
Schedule: MTWHFS
Instructor: Captain Hook
More courses? n
More students? n
Here shows the students’ records:
******************
Student Name: John Smith
Student ID: 000123456
Year in school: 2
GPA: 4.0
Courses:
Name:CS1
Number: 1470
Schedule: MWF
Instructor: Wei
Name: DataStructure
Number: 2320
Schedule: TH
Instructor: Jim
*****************
Student:
Name: Peter Pan
......
......
// And here's my current code
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int NAME_SIZE = 50;
const int ID_SIZE = 10;
const int COURSE_SIZE = 10;
const int CNAME_SIZE = 50;
const int DAYS = 5;
Here is your attempt to call the function. It makes no sense. The function accepts an array of Student, and an int.
Here is what I expect you meant to do: getStudentInfo(students, NUM_STUDENTS)
How to call a function is very very basic. If you are getting this wrong, stop. Go back. Learn what a variable is and how to use one. Learn what a function is and how to use one.
I actually expected the index of the students array to be passed into the function. Needs documentation on what that second integer parameter is supposed to be. I imagined it like so:
It's not feature-complete but is one way to solve the filling of the array with a little test on the year to see if a student had been added. No idea why you'd want the original method signature to fill the array...