KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was reading about volatile member function and came across an affirmation that member function can be both const and volatile together . I didn't get the real use of such a thing. Can anyone please share their experience on practical usage of having member function as const and volatile together. I wrote small class to test the same: class Temp { public: Temp(int x) : X(x) { } int getX() const volatile { return X; } int getBiggerX() { return X + 10; } private: int X; }; void test( const volatile Temp& aTemp) { int x = aTemp.getX(); } int main(int argc, char* argv[]) { const volatile Temp aTemp(10); test(aTemp); return 0; }
Tags (comma-separated)
Save Edits
Cancel