How do I setup an array in C++ with a constant as the max size allowed? -


class grades { private:    char *grade;    string course[20];    int numcourse; public:    grades();    bool setgrade(char *gradein);    bool setcourse(char *namein);  }; 

so that's class declaration. want set constant number instead of 20 in array declaration. how go doing that? have tried static const problem every time class returns error saying out of scope.

this doesn't work?

class grades { private:    char *grade;    static const int max_courses = 20;    string course[max_courses];    int numcourse; public:    grades();    bool setgrade(char *gradein);    bool setcourse(char *namein);  }; 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -