Q:

What is the important memory allocation flaw that is seen here?

Actually this was a homework I got. But I do not know the answer. Can anyone please help me?
What is the important memory allocation flaw that is seen in the following C++ code? How can you avoid it?
void testFunction(){
   int * p = new int(5);
   cout << p << *p << &p << endl;
}

A:

The memory is never released, so you have a memory leak. You can fix this by deleting the pointer:
void testFunction(){
   int * p = new int(5);
   cout << p << *p << &p << endl;
   delete p;
}

