const_cast 用于将常量对象转换成非常量对象。

    1. void main() {
    2. const char* ch = "BDEF";
    3. char *sh = const_cast<char *>(ch);
    4. cout << sh << endl;
    5. sh = const_cast<char*>("faf");
    6. cout << sh << endl;
    7. cout << ch << endl;
    8. system("pause");
    9. }