c++ - When is a non-static const data member more useful than a const static one? -


in c++ there static , non-static const data members. when want constant, make static because not make sense have multiple copies (one per each instance of class) if item cannot modified. know why there non-static const members?

  1. a static const applies class
  2. a const applies object

e.g.

class verticies {     public:        const int colour;        static const int max_verticies = 100;        point points[max_verticies];        verticies(int c) : colour(c) { }        // etc }; 

here max_verticies applies objects of type verticies. different objects have different colours , colour fixed on construction


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -