PDA

View Full Version : [C++] Quick question about "const"



kahumba
December 30th, 2009, 11:50 AM
Hi,
Am I assuming correctly the following?


int func() {
static const int y = 15;//initiated only once and can't change
const int z = 23;//initiated every time and can't change
return y + z;
}

dwhitney67
December 30th, 2009, 12:18 PM
It seems correct to me. Someone else may be able to explain it in 500 words or less, but from how you describe it, it is correct.

P.S. Most people use the word "initialized" versus "initiated".

kahumba
December 30th, 2009, 12:26 PM
Oh thanks!