正在加载图片...
Static Class Member -Data Members (cont, Static data members Only one entity among all objects of this class All objects share the static data members and access them Should be defined and initialized outside the cla vector<int> CFibonacci: s elems definition and intialized as an empty vector, like global variables Iclass scope is needed, but keyword"static"is no more needed int Fibonacci s iDefaultPos =8: / definition and initialized Const objects could be done in the class [other pal ate: static const int s_iBuffSize = 1024; //Compiler dependent int m Buffer[s iBuffSize]Static Class Member – Data Members (cont.) ◼ Static data members ◼ Only one entity among all objects of this class ◼ All objects share the static data members and access them ◼ Should be defined and initialized outside the class vector<int> CFibonacci::s_elems; //definition and intialized as an empty vector, like global variables //class scope is needed, but keyword ”static” is no more needed int Cfibonacci::s_iDefaultPos = 8; //definition and initialized ◼ Const objects could be done in the class { //Other parts private: static const int s_iBuffSize = 1024; //Compiler dependent int m_Buffer[s_iBuffSize]; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有