开发者

shared_ptr as class member corrupts stack?

开发者 https://www.devze.com 2023-02-21 17:45 出处:网络
I have a shared_ptr开发者_如何学运维 in the class like this class App { public: App(){}; ~App(){};

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


The code you pasted is fine, shared_ptr has a sensible default ctor and will destruct fine

0

精彩评论

暂无评论...
验证码 换一张
取 消