Mars_999
2002.07.25, 01:35 AM
Not sure why this code dont' work?
struct FOO
{
int a;
};
const int arraysize = 10;
int main(int argc, char *argv[])
{
FOO *foo[arraysize][arraysize] = new FOO; //why don't this work?
FOO *foo[arraysize][arraysize] = new FOO[arraysize][arraysize]; // this dont' work either?
int *x = new int; // this is the correct syntax
return 0;
}
I think the reason why the first dont' work is the compiler dosen't know how much RAM to allocate? The second would seem logical to solve that but it don't work? I know the last one works, since that is the syntax for a pointer using new. =) Thanks
struct FOO
{
int a;
};
const int arraysize = 10;
int main(int argc, char *argv[])
{
FOO *foo[arraysize][arraysize] = new FOO; //why don't this work?
FOO *foo[arraysize][arraysize] = new FOO[arraysize][arraysize]; // this dont' work either?
int *x = new int; // this is the correct syntax
return 0;
}
I think the reason why the first dont' work is the compiler dosen't know how much RAM to allocate? The second would seem logical to solve that but it don't work? I know the last one works, since that is the syntax for a pointer using new. =) Thanks