identifier is undefined

Jul 4, 2018 at 8:33am
I've been stuck on this one for awhile. Seemingly eliminated all bugs from my code except for this one.

the below is declared in my .h publicly
 
  void printDaysInCourse(string studentID);


this is privately in .h
1
2
 
Student** classRosterArray;

i then define the printsDaysInCourses function in the .cpp. I'll leave that out, unless it's needed. Here's where i run into the problem, in main, I have this:
1
2
3
4
	for (int c = 0; c < numStudents; c++)
	{
		classRoster->printDaysInCourse(classRosterArray[c]->getID());
	}

When I do this I get the error "identifier "classRosterArray" is undefined, and also "left of '->getID' must point to class/struct/union/generic type"
Jul 4, 2018 at 8:40am
At that point in the code, the compiler has no idea what classRosterArray is. In a function, three kind sof objects can be seen.

1) Input parameters to the function
2) Global objects
3) Objects that were made inside that function
4) If inside a class, class member variables.

Clearly, classRosterArray is none of these. At that point in the code, the compiler has no idea what classRosterArray is.
Jul 4, 2018 at 9:36am
Oh ok, I had thought it was a class member variable but I guess it isn't since it is really a pointer to an array in another class
Topic archived. No new replies allowed.