- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the volatile keyword mean in C++?
volatile means two things −
- The value of the variable may change without any code of yours changing it. Therefore whenever the compiler reads the value of the variable, it may not assume that it is the same as the last time it was read, or that it is the same as the last value stored, but it must be read again.
- The act of storing a value to a volatile variable is a "side effect" which can be observed from the outside, so the compiler is not allowed to remove the act of storing a value; for example, if two values are stored in a row, then the compiler must actually store the value twice.
As an example −
i = 2; i = i;
The compiler must store the number two, read the variable i, store the variable that it read into i.
You can find more details on the volatile keyword here − https://www.geeksforgeeks.org/understanding-volatile-qualifier-in-c/
- What does the restrict keyword mean in C++?
- What does the explicit keyword mean in C++?
- What is volatile keyword in C++?
- volatile keyword in C#
- What does the KEY keyword mean in MySQL?
- volatile Keyword in Java
- What does the modifier volatile in Java do?
- Can we make Array volatile using volatile keyword in Java?
- What does the keyword var do in C#?
- What does the [Flags] Enum Attribute mean in C#?
- What does the operation c=a+++b mean in C/C++?
- What does the two question marks together (??) mean in C#?
- What does an auto keyword do in C++?
- What does these operators mean (** , ^ , %, //) ?
- What does the Star operator mean in Python?