class A {
struct structA;
}
其他地方:
structA* structAPointer = new structA;
一片遥远的土地:
void Wonderland::rabbitHole(structA* structAPointer) {
delete structAPointer;
}
delete运算符是否会释放在“其他地方”分配的原始内存?
class A {
struct structA;
}
其他地方:
structA* structAPointer = new structA;
void Wonderland::rabbitHole(structA* structAPointer) {
delete structAPointer;
}
delete运算符是否会释放在“其他地方”分配的原始内存?
std::shared_ptr
。 - Shoe
structAPointer
来调用rabbitHole
,则是这样的。 - Shoedelete
运算符释放的是内存地址,而不是保存它的变量。 - Shoe