Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


When volatile can be used?

Answers were Sorted based on User's Feedback



When volatile can be used?..

Answer / reejusri

One more thing i want to add in above answer that is if
compiler sees keyword volatile it skips that variable from
optimization of code, becasue since it is very dymanic in
nature and to manage such type of variable for
optimaization is costly.

Is This Answer Correct ?    7 Yes 0 No

When volatile can be used?..

Answer / mustafa

Volatile restricts the compiler in two ways
1-> No optimization algorithm should be applied to this
variable.
2-> When ever you need the value of the volatile variable
please take it from the memory.

Is This Answer Correct ?    7 Yes 0 No

When volatile can be used?..

Answer / qqlin

it means this value will be changed unexpectedly. everytime
the program wants to use it, it can only be got from memory
but not from the register directly.

if you want a variable can be accessed by several threads,
you need this key word, like in ISR program, etc.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer



More C++ General Interview Questions

How do you invoke a base member function from a derived class in which you’ve overridden that function?

0 Answers  


How do I get good at c++ programming?

0 Answers  


How the endl and setw manipulator works?

0 Answers  


What is the basic concept of c++?

0 Answers  


Explain the scope of resolution operator.

0 Answers  






When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

0 Answers  


Write a program to reverse a linked list?

8 Answers   Catalytic Software, Satyam,


What is the difference between reference type and pointers.

4 Answers   HCL,


how to swap two numbers with out using temp variable

12 Answers   Global eProcure, TCS,


1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?

5 Answers  


what is C++ exceptional handling?

0 Answers  


simple c++ program for "abcde123ba" convert "ab321edcba" with out using string

5 Answers  






Categories