Two different values at the same memory address

前端 未结 7 659
春和景丽
春和景丽 2020-11-22 08:14

Code

#include 
using namespace std;

int main() {
    const int N = 22;
    int * pN = const_cast(&N);
    *pN = 33;
    co         


        
相关标签:
7条回答
  • 2020-11-22 09:04

    const_cast in your code, just hands over a pointer 'Pn' to 'N' through which 'N' can be modified. The address of 'N' remains the same as the handed over pointer 'Pn'

    0 讨论(0)
提交回复
热议问题