开发者

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

Like:

class A
{
     volatile int i;
};


A a;

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜