Tuesday, December 19, 2006

if we forget destroy


#include

using namespace std;

int fnBuildInt()
{
int *p = new int(1);
return *p;
}


void test()
{
int i = fnBuildInt();
}


int main()
{
while(true)
test();
return 0;
}

// this is what we called memory leak

0 Comments:

Post a Comment

<< Home