Question: C++ classes HELP. I have this coding homework and I dont understand what it is wanting differently. It is a program that reads in a

C++ classes HELP. I have this coding homework and I dont understand what it is wanting differently. It is a program that reads in a file that is basically a course directory states how many classes are in the file then, class code [like MATH or EECS], then code number, number of students and then all student id's for that class. I thought that the section where it is reading in the file would work but it is saying the courses.[blah] has not been declared.... So not sure what I should do... in order is the executive.cpp file, then exectutive.h and then main.cppC++ classes HELP. I have this coding homework and I dont understandwhat it is wanting differently. It is a program that reads ina file that is basically a course directory states how many classesare in the file then, class code [like MATH or EECS], thencode number, number of students and then all student id's for thatclass. I thought that the section where it is reading in thefile would work but it is saying the courses.[blah] has not beendeclared.... So not sure what I should do... in order is theexecutive.cpp file, then exectutive.h and then main.cpp 253 254 255 256 257

258 259 260 261 262 263 264 265 266 267 268 269

253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 printall); swap (courses [firstIndex].courseName, courses [secondIndex].courseName); void Executive:schedule int ID; cout > ID; cout > dept; 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 for (int i0i courseNo; cout > dept2 for (int j 0; j courseNo2 for ( int x=; x max) max courses [1] .numStudents; for(int i- 0: i department; for(int i0: i courseNum; for ( int =0; > option; while (option >7 I option > option: if (option1) printall ) 37 38 39 40 41 42 43 while (getline (file, line)) i 0: char str = const cast-char>(line. c str ( ) token= strtok (str, " "); while (token NULL) 45 46 47 48 49 50 51 52 53 54 if (j-0) strcpy (courses[i].courseName, token) else if (j - 1) courses[i].courseNum-atoi (token) else if(j-2) 56 57 58 59 60 61 62 63 64 65 courses [i].numStudentsatoi (token): else courses [1]. IDs [j - 3] = atoi (token); token = strtok (NULL, " "); 67 68 69 70 71 72 73 file.close ) include"executive.h" #include #include #include #include #include sstream> #include 2 7 9 10 using namespace std; Executive::Executive (string n) 12 13 14 15 16 17 18 19 20 21 EileNamen; Executive courses courses.courseName courses.courseNum; courses.numStudents: courses. IDs: void Executive::run () 23 24 25 26 27 28 29 30 31 32 int num courses: int i 0 int //Reading information from file ifstream file: file.open (fileName) file >> num courses; char *token; if (file.fail 0) 34 35 36 37 string line, temp; while (getline (file, line)) #1fndef EXECUTIVEH #define EXECUTIVE H #include #include #include "executive . h" using namespace std; int main( int argc, char* argv[]) if(argc > ID; cout > dept; 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 for (int i0i courseNo; cout > dept2 for (int j 0; j courseNo2 for ( int x=; x max) max courses [1] .numStudents; for(int i- 0: i department; for(int i0: i courseNum; for ( int =0; > option; while (option >7 I option > option: if (option1) printall ) 37 38 39 40 41 42 43 while (getline (file, line)) i 0: char str = const cast-char>(line. c str ( ) token= strtok (str, " "); while (token NULL) 45 46 47 48 49 50 51 52 53 54 if (j-0) strcpy (courses[i].courseName, token) else if (j - 1) courses[i].courseNum-atoi (token) else if(j-2) 56 57 58 59 60 61 62 63 64 65 courses [i].numStudentsatoi (token): else courses [1]. IDs [j - 3] = atoi (token); token = strtok (NULL, " "); 67 68 69 70 71 72 73 file.close ) include"executive.h" #include #include #include #include #include sstream> #include 2 7 9 10 using namespace std; Executive::Executive (string n) 12 13 14 15 16 17 18 19 20 21 EileNamen; Executive courses courses.courseName courses.courseNum; courses.numStudents: courses. IDs: void Executive::run () 23 24 25 26 27 28 29 30 31 32 int num courses: int i 0 int //Reading information from file ifstream file: file.open (fileName) file >> num courses; char *token; if (file.fail 0) 34 35 36 37 string line, temp; while (getline (file, line)) #1fndef EXECUTIVEH #define EXECUTIVE H #include #include #include "executive . h" using namespace std; int main( int argc, char* argv[]) if(argc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!