static data in c++ class

e:\books\2013\c++\C++.Primer.Plus.6th.Edition.pdf

 

C++ has a second way of defining a constant within a class—using the keyword static:
class Bakery
{
private:
static const int Months = 12;
double costs[Months];
...
This creates a single constant called Months that is stored with other static variables
rather than in an object.Thus, there is only one Months constant shared by all Bakery
objects. Chapter 12 looks further into static class members. In C++98 you can use this
technique only for declaring static constants with integral and enumeration values.Thus,
C++98 doesn’t allow you to store a double constant this way. C++11 removes that
restriction.

chapter 12

A Review Example and Static Class Members

阅读更多
个人分类: android
上一篇Media player service not published, waiting...
下一篇watchdog in android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭