CourseList* courseList[100] does not create a pointer to an array, it creates an array of pointers. Depending on what you actually want you should be using one of the following
An array of CourseLists
CourseList courseList[100]; // possibly with = {} courseList[0].attr = whatever; // usage
Better than the above, but similar, a std::array of CourseLists
std::array<CourseList, 100> courseList; // possibly with = {} courseList[0].attr = whatever;
Or the closest to what it seems you want, a pointer to a std::array of CourseLists. This is probably not best, but nonetheless, here it is:
std::array<CourseList, 100>* courseList = nullptr; courseList = new std::array<CourseList, 100>{}; // prefer unique_ptr courseList->at(0).attr = whatever;
If you don't know the size at compile time, or want to pass around the object, your best bet is to use a std::vector
std::vector<CourseList> courseList(100); courseList[0].attr = whatever;
Finally, the weirdest option would be to actually define a pointer to an array:
CourseList (*courseList)[100] = nullptr;
Addressing the update: you can just use default initializers in your class like so:
class ScmApp { private: CourseList* courseList[100] = {}; int noOfCourses = 0; };
But it seems like you should be using a growable container, std::vector and calling push_back to repeatedly add courses. What I see is a very hard-to-maintain keeping track of who is in what class.
If it is absolutely necessary that you take an existing array and set everything to nullptr then you can use std::fill
std::fill(std::begin(courseList), std::end(courseList), nullptr);
Course* courseList(100, null);does the same thing.CourseListis not a pointer, it is an array of pointers. Do you want to set each element tonullptr?courseListis an array. You cannot set arrays to null, just like you cannot set cats or dishwashers to null. Only pointers can be null.Course* courseList[100] = {nullptr};do the job?