employer cover photo
employer logo
employer logo

Obsidian Entertainment

Is this your company?

Obsidian Entertainment interview question

What is the volatile c++ keyword?

Interview Answers

Anonymous

16 Jan 2016

"Answer: It's compiler hint, asking the compiler not to optimized away the labeled variable," is only a half answer. Volatile tells the program a value can be changed at any time, so it can't cache the value. It forces the program to retrieve the value from memory. Concerning it's use and possible uses, things can get complex in C++.

2

Anonymous

31 July 2020

It is useful in multithreading, when semaphores are needed, and multiple threads affect the value. It ensures that the most up to date value is loaded in.

Anonymous

2 Aug 2013

The other questions were reasonable programming and math questions, but that one struck me as random trivia question. Answer: It's compiler hint, asking the compiler not to optimized away the labeled variable.