I have studied in C++ Primer that the dimension of an array should be a const expression but the following code compiles and gives the desired result. Why?
#include<iostream>
using namespace std;
int main()
{
unsigned int bufsize = 10;
int h[bufsize]={};
for(int i=0; i<=9; i++)
cout<<h[i]<<endl;
}
But if I add the following:
constexpr int a = bufsize;
Then the compiler shows error meaning that bufsize is not a constant expression then why is the program compiling correctly otherwise if the dimension of the array should be constant expression