Data Types and Structs

Posted by dubya on Stack Overflow See other posts from Stack Overflow or by dubya
Published on 2010-04-30T14:28:49Z Indexed on 2010/04/30 14:37 UTC
Read the original article Hit count: 273

Filed under:
|
|

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; 
  1. 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.

© Stack Overflow or respective owner

Related posts about struct

Related posts about datatypes