Are const arrays declared within a function stored on the stack?
c++, stack
Solution
Yes, they're on the stack. You can see this by looking at this code snippet: it will have to print the destruction message 5 times.
struct A { ~A(){ printf( "A destructed\n" ); } };
int main() {
{
const A anarray [5] = {A()} ;
}
printf( "inner scope closed\n");
}
Problem
if this was declared within a function, would it be declared on the stack? (it being const is what makes me wonder) ``` void someFunction() { const unsigned int actions[8] = { e1, e2, etc... }; } ```