in place new


// https://www.online-cpp.com/
#include<iostream>
using namespace std;
int main() {
    char c1 = '1';
    cout << c1 << endl;
    char *pc2 = new (&c1) char;
    cout << c1 << endl;
    c1 = '2';
    cout << *pc2 << endl;
    return 0;
}
// 1
// 1
// 2

posted @ 2024-08-08 18:41  joel-q  阅读(3)  评论(1编辑  收藏  举报