C++ 中的字符串字面量是否在静态内存中创建并仅在程序退出时销毁?
最佳答案
是的,字符串字面量在程序的整个过程中都有效,即使在静态对象的销毁期间也是如此。
标准中的 2.13.4/1 说
An ordinary string literal has type "array of n const char" and static storage duration.
标准在 3.7.1/1 中提到“静态存储持续时间”:
The storage for these objects shall last for the duration of the program.
关于c++ - С++ 中的字符串文字是在静态内存中创建的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/349025/