C++ POD types

參考這個頁面

https://www.jianshu.com/p/0e7939d792d1

在一個結構體內寫了構造函數後

從:
struct aa
{
    int a;
    int b;
}
修改爲:
struct aa
{
    int a;
    int b;
    aa()
    {
        a = 0;
        b = 0;
    }
}
後
再用
struct aa test1;
memset(&test1,0,sizeof(struct aa));

kw就會報錯,在一個non-pod對象上使用了memset

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章