I'm reviewing for a test, and I am stumped by this question.
Consider the following declarations:
enum CategoryType {HUMANITIES, SOCIALSCIENCE, NATURALSCIENCE};
const int NUMCOURSES = 100;
struct CourseRec
{
string courseName;
int courseNum;
CategoryType courseCategory;
};
typedef CourseRec CourseList [NUMCOURSES];
CourseList courses;
int index1, index2;
- What is the data type of the expression courses[index1] .courseName[index2] ?
(a) CourseList (b) CourseRec (c) string (d) char (e) none; the expression is syntactically invalid
I thought that the answer would be string, since courseName is a string, or maybe even CourseRec, since it is in the struct, but the answer is (d)char. Why is this a char data type? Any help is greatly appreciated.