Howdy everyone.
an simple question. I declare the const like this:
const int x;
x=0;
but it failed when compiling. Could we declare the const first and valued it later ?
Howdy everyone.
an simple question. I declare the const like this:
const int x;
x=0;
but it failed when compiling. Could we declare the const first and valued it later ?
Never end on learning~
Constants are declared like this.
const int x = 0;
What you did was say, i want this integer x to be constant. Then the compiler says ok, now nothing can change it. Then you said i want to change it now to 0. That is why it didn't let you, you cannot do that with 2 statements like you have. Put them all on the same one and you will be fine.
got it, thanx.Originally posted by MrWizard
Constants are declared like this.
const int x = 0;
What you did was say, i want this integer x to be constant. Then the compiler says ok, now nothing can change it. Then you said i want to change it now to 0. That is why it didn't let you, you cannot do that with 2 statements like you have. Put them all on the same one and you will be fine.
Never end on learning~