using structures and unions

how should a structure be used in other functions?
how should a prolem like this be solved?
Consider the abstract data type, aStudent, described as:
struct aCourse
{
char * code;
int credit_hrs;
double marks;
};
struct aStudent
{
char * ID;
double OMW;
aCourse * course; // a list of courses the student is taking
int totalCourses; // max. no. of courses the student is taking
};
a) i) Write a C++ function
bool found(char * ID_token, aStudent * student, int N)
{
// C++ code here
}
that returns true if the ID_token can be found as one of the students’ IDs in the
given list of students, student, of length N. It returns false otherwise. The function
should apply the linear search algorithm.
HINT: You may assume the existence of the function: bool equal(char * str1,
char * str2), which returns true if str1 is the same as str2, false otherwise.
ii) Write any legitimate C++statement that initiates a call to the found(...) function
above. Assume that the variable, student, has been properly declared and populated
and N = 100.
Last edited on
The same way as classes...

Class == Struct == Union, except:
Classes default to private members and private inheritence unless otherwise specified
Structs default to public members and public inheritence unless otherwise specified
Unions default to public members and public inheritence unless otherwise specified, and all data members take the same space and must be PODs.
Topic archived. No new replies allowed.