I know that non-type template argument for intgral type must be const expression so:
template <int E> class cat { public: int array[E]; }; int main() { cat<4> ob; // ?? } From what I've read only const variables that get initialized with const expressions are const expressions. In this example, we have int E = 4;, so E will not be a constexpression.
So why doesn't cat<4> ob; throw an error? Am I missing something here?
And how will int array[E]; be created if E is not known at compile time?
4is a compile time constant.