"The C++ compiler can only allocate an array with a size known at compile time. If you want to allocated a variable size piece of memory, use the new operator."
http://stackoverflow.com/questions/4589463/initialize-array-size-from-another-array-value On Jan 3, 4:58 pm, Aniket <[email protected]> wrote: > #include<iostream> > using namespace std; > const int a[]={1,2,3,4,5}; > int b[a[2]]; > int main(){return 0;} > > If the code is like above it is giving error in line 4; > > But if it is something like below it gives no error after compilation: > > #include<iostream> > using namespace std; > const int a=3; > int b[a]; > int main(){return 0;} > > Anybody please expalin. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
