Really there are two problems with this code.
main.cpp|19|error: ISO C++ forbids zero-size array ‘classList’ [-Wpedantic]|
main.cpp||In constructor ‘student::student(std::string, int, std::string*)’:|
main.cpp|34|error: invalid initializer for array member ‘std::string student::classList [0]’|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
For the second error you're probably going to need to initialize this array inside the constructor body.
1 2 3 4 5 6
student::student(string StudentName, int ClassCount, string classNames[])
:name(StudentName), numClasses(ClassCount), classList()
{
for(int i = 0; i < numClasses; ++i)
classList[i] = classNames[i];
}
It depends whether you want to create the array dynamically or not.
If the array is always the same size then just create it as you would normally with appropriate gets and sets using ponters.
If the size of the array isn't known at compile time then you have to create it using new, delete etc passing the required size to the class member function at runtime. You still use pointers along with gets and sets as appropriate. In the constructor there are several ways of passing the subject list to the class.