Saturday, May 29, 2010

const Data Member

const int x = 5;

If a variable is declared as “const”, it is known as “const data member” and it is not possible to change the value x.

Example:

const int x = 5; x = 7;

The above code results an error while compiling because x is declare as constant and it is not possible to change the value of x.

No comments:

Post a Comment