Here is a code example:
#includeusing namespace std; class A { public: void volatile_func() volatile { cout << " volatile_func" << endl; } void non_volatile_func() { cout << "non_volatile_func" << endl; } void const_func() const { cout << " const_func" << endl; } void non_const_func() { cout<< " non_const_func" << endl; } }; int main() { volatile A aVolatile; A aNonVolatile; const A aConst = A(); A aNonConst; aVolatile.volatile_func(); /////////////////////////////////////// // The following line does not compile. // aVolatile.non_volatile_func(); /////////////////////////////////////// aNonVolatile.volatile_func(); aNonVolatile.non_volatile_func(); aConst.const_func(); /////////////////////////////////////// // The following line does not compile. // aConst.non_const_func(); /////////////////////////////////////// aNonConst.const_func(); aNonConst.non_const_func(); return 0; }
No comments:
Post a Comment