Can you give an example of stack overflow in C++?

后端 未结 12 1576
不知归路
不知归路 2020-12-31 18:52

Can you give an example of stack overflow in C++? Other than the recursive case:

void foo() { foo(); }
12条回答
  •  萌比男神i
    2020-12-31 19:34

    Compile-time example:

    template 
    struct Factorial {
        enum { value = N * Factorial::value };
    };
    
    // ...
    {
        int overflow = Factorial<10>::value;
    }
    

提交回复
热议问题