Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I declare an instance variable as volatile, will the object of this class be volatile?

Tags:

c++

volatile

Like:

class A
{
     volatile int i;
};


A a;

My question is that will the entire a become cv qualified? May be a naive question.

like image 298
Dai Haoci Avatar asked Aug 01 '11 22:08

Dai Haoci


1 Answers

No, all of a will not be volatile. Just as you can have fields of a class that are const without every instance of the class being const, you can have volatile fields that do not make the entire class instance volatile.

like image 60
templatetypedef Avatar answered Sep 19 '22 12:09

templatetypedef