且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在访问数据时遇到问题

更新时间:2023-01-23 17:06:55

将数据设为静态有什么用?

what about making the Data as static?

class X
{
public:
   static uint32_t Data;
};




改进后,您必须在基类的基础上提及public. (If you do not choose an inheritance type, C++ defaults to private inheritance)




Improved, you have to mention public where inhering from the base class. (If you do not choose an inheritance type, C++ defaults to private inheritance)

class Y : public X
{
public:
};


类的静态成员必须初始化:

Static members of a class must be initialized:

Y Z::y;

int main()
{
    ...