Jumat, 03 Februari 2017

How to prevent modification of objects in C++ using volatile

An object which can be modified by some unknown force (like hardware io) other than the programs itself can be declared as volatile. The compilers doesn’t apply any optimization for such volatile object. The syntax for declaring a volatile objects is as follow: volatile ClassName object-name;   A member functions can be declared as volatile to make the access to members variable to be volatile. A volatile object can access only volatile function. The syntax for creating a volatile functions is as follows: return-type function-name(args) volatile;   Following programs demonstrates both volatile objects and volatile program: 1 2 3 4

The post How to prevent modification of objects in C++ using volatile appeared first on Coding Security.


How to prevent modification of objects in C++ using volatile
read more

Tidak ada komentar:

Posting Komentar