C++, preventing class instance from being created on the stack (during compiltaion)

前端 未结 5 732
谎友^
谎友^ 2020-12-29 00:29

I know there are methods to prevent a class from being created on the heap, by preventing the user from using the new and delete operator. I am try

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 00:57

    It isn't. The compiler is trying to call the destructor when it goes out of scope, and is indicating to the line of code that produces this effect, which is much more useful than pointing at the end of the function.

提交回复
热议问题