I am brand new to C++ and am struggling with the idea of using arrays and returning pointers.
I have a class Student in a .h file:
class Student {
public:
// stuff
int* GetNumDaysPerCourse() const;
// stuff
private:
//stuff
int numDaysPerCourse[3];
// stuff
};
And I am trying to implement it in a .cpp file:
int* Student::GetNumDaysPerCourse() const {
return numDaysPerCourse;
}
But I am getting an error saying:
return value type does not match the function type
I am confused because looking at other questions, this looks like a valid way to do this.
So, how do I return a class member array using a getter in C++?