Shared_ptr 作为类成员会破坏堆栈吗?
当我在 main 中实例化一个 App 类时,我的类中有一个共享指针
class App
{
public:
App(){};
~App(){};
private:
boost::shared_ptr<int> ab;
};
,堆栈会损坏吗?
int main(){
App myApp;
}
有谁知道为什么会出现错误:“运行时检查失败#2 - 变量‘myApp’周围的堆栈已损坏。”在 Visual Studio 中出现?
shared_ptr 不需要初始化它无论如何都会为零? 这很奇怪
I have a shared_ptr in the class like this
class App
{
public:
App(){};
~App(){};
private:
boost::shared_ptr<int> ab;
};
when I instanciate one App class in main, the stack gets corrupted?
int main(){
App myApp;
}
Does any one know why the error :" Run-Time Check Failure #2 - Stack around the variable 'myApp' was corrupted." appears, in Visual Studio?
shared_ptr needs no initialization it will be zero anyway or not?
This is quite strange
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您粘贴的代码很好,shared_ptr 有一个合理的默认构造函数,并且会很好地破坏
The code you pasted is fine, shared_ptr has a sensible default ctor and will destruct fine