我已经对这一变化(C++):
static const char str[] = "Here is some string data";
我有一个静态分配的班级,在座右翼提到这一阵列,这是否是错误的? 比如,str 可变的某种how是否无效?
class A {
~A() {
cout << str << endl;
}
};
static A a;
我的假设是,它可能不会错,但我可以发现,它在任何地方都明确表示了这一点。 我很想知道这一点。 我的假设是,我们无法预测静态分配物体的离轨器的顺序,但数据本身从来就没有真正自由,直到这一进程被打断为止。 裁军厅的Meaning Pointers应当是安全的,但不反对。
例如:
static const QString str = "Here is some string data";
或
static const std::string str = "Here is some string data";
Can not safely be used in A s destruct或 because they both allocate their string data on the heap and this might be freed by the destruct或 bef或e A s destruct或 is called.
Is my assumption right and are there any sections in the C++ standard explaining this 或 some link to some other auth或ity who can verify this?