cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Using const and volatile simultaneously
Using const and volatile simultaneously
Jul 17, 2011 at 3:13pm UTC
ChosenTorture
(47)
I have heard and read that
const
and
volatile
can be used simultaneously for member functions and variables but i didn't exactly understand the purpose of using them like that. Can anybody explain the purpose of such a feature in C++ ?
Jul 17, 2011 at 3:18pm UTC
jsmith
(5804)
A data member of a class may be declared volatile because, for example, it might represent the value stored in some memory mapped PCI port.
A accessor function for the data member is probably declared const.
Inside the accessor function, the data member is actually a const volatile.
Topic archived. No new replies allowed.