C++ volatile member functions

后端 未结 4 2058
礼貌的吻别
礼貌的吻别 2020-12-02 15:48
class MyClass
{
    int x, y;
    void foo() volatile {
        // do stuff with x
        // do stuff with y
    }   
};

Do I need to declare

4条回答
  •  囚心锁ツ
    2020-12-02 16:14

    You don't have to declare the member variables explicitly..

    From Standard docs 9.3.2.3,

    Similarly, volatile semantics (7.1.6.1) apply in volatile member functions when accessing the object and its nonstatic data members.

提交回复
热议问题