C++ Programming questions
I am trying to port some code snippets from Windows to OSX,it is something that is run from the console,but I have trouble compiling it-I keep getting one warning a bout a variable,or rather an array being unitialized here is the error message and the code:
unitialized const 'null'
const double *G5i::coordinates(int grade) const {
int ia = 0;
int i, j = 1, gu = gradeUsage();
static const double null[32];
for (i = 0; i < 6; i++) {
if (j == grade) return (gu & j) ? c + ia : null;
if (gu & j) ia += G5i_gradeSize[i];
j <<= 1;
}
return null;
}
I tried to initialize it by using:
for (i = 0; i < 32; i++) {
null[i] = 0.0;
}
but that caused even more problems.
The other question is,if I am not able to compile this,where can a get a good free C++ compiler for Windows2000? Any information would be apppreciated.
unitialized const 'null'
const double *G5i::coordinates(int grade) const {
int ia = 0;
int i, j = 1, gu = gradeUsage();
static const double null[32];
for (i = 0; i < 6; i++) {
if (j == grade) return (gu & j) ? c + ia : null;
if (gu & j) ia += G5i_gradeSize[i];
j <<= 1;
}
return null;
}
I tried to initialize it by using:
for (i = 0; i < 32; i++) {
null[i] = 0.0;
}
but that caused even more problems.
The other question is,if I am not able to compile this,where can a get a good free C++ compiler for Windows2000? Any information would be apppreciated.
Comments
static const double null[32] = {0.0, 0.0, ... 0.0};
BTW, I looked up the answer here:
<a href="http://www.amman.edu/cpp/Arrays/Arrays.html" target="_blank">http://www.amman.edu/cpp/Arrays/Arrays.html</a>
<strong>Yeah,that's what I ended up doing.I understand const,I don't understand why it can't be initialized with a loop.</strong><hr></blockquote>
const objects can't be changed, and can only be set in their instantiation. otherwise the compiler can't guarantee the integrity of their constant-ness. making a loop would force the const[ant] objects to change [out of their instantiation]. constant change == no no.