. What wrong with the following code segment?

    int* = needle;
    needle = new int;
    *needle 100;
    cout << *needle;
    needle = new int;
    *needle = 32;
    cout << *needle;

Recommended Answers

All 2 Replies

lines 1 and 3 are not valid statements. Also, there is a memory leak on line 4 because it doesn't delete the pointer allocated on line 2.

int* = needle doesn't make sense and *needle 100 have you even tried running it in a compiler?

Be a part of the DaniWeb community

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