遇见YY

导航

 
#include <iostream>

class Example {
public:
    Example() {
        std::cout << "Default Example!" << std::endl;
    }

    Example(int id) : ID(id) {
        std::cout << "Example!" << std::endl;
    }


    virtual ~Example() {
        std::cout << "~Example:" << ID << std::endl;
    }

private:
    int ID;
};

int main() {
    Example example(0);
    example.~Example();
    new(&example)Example(1);
    return 0;
}

posted on 2021-01-15 10:42  一骑红尘妃子笑!  阅读(906)  评论(0编辑  收藏  举报