What wrong with the following code segment?

    int* birdDog;
    int* germanShortHair;
    birdDog = new int;
    germanShortHair = birdDog;
    *birdDog = 42;
    cout << *birdDog;
    delete birdDog;
    cout << *germanShortHair;

line 8 points to an address that was deleted in line 7. Once the memory is deleted you can't reference it again.

commented: This explains well DaMaskMan2's question. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.