首页 > 解决方案 > how to limit scope of overloaded new/delete operator to translation unit only (when they can not be made static)

问题描述

While moving the project from Visual Studio 2010 to 2017 I am facing a problem. One of the projects has global static overloaded new/delete operators, on compiling with VS2017 it throws an error that new/delete operators can not be declared static (it used to compile on VS2010). But static ensures scope of these overloaded new/delete specific to a translation unit. How this can be achieved when no more static new/delete operators are allowed. Please help me with the suggestions.

标签: c++visual-studio-2017

解决方案


在 CPP 文件中提供声明和定义。这将限制特定编译单元的可见性


推荐阅读