C++如何将其作为构造函数内的易失性指针

C++ how to make this as a volatile pointer inside constructor

本文关键字:构造函数 易失性 指针 C++      更新时间:2023-10-16

我知道我可以在成员函数声明的末尾添加volatile关键字,使该指针变为volatile,但如何在构造函数中做到这一点?

class A {
    void method() volatile; // inside method this is volatile pointer.
    A() {;} // How to make this as volatile pointer here.
}

感谢

this标记为volatile没有任何意义,因为this指针的值对于任何给定对象都是恒定的,在任何情况下都不能更改。