adapanaidu
April 17th, 2007, 04:31 AM
#include <iostream>
#include <map>
using namespace std;
int main()
{
map < int , string > sampMap;
map < int , string > sampMap1;
sampMap[1] = "Adams";
sampMap[2] = "Peter";
map < int , map< int , string >> tempMap;
tempMap[1] = sampMap;
sampMap1 = tempMap[1];
sampMap1[3] = "Thomson";
tempMap[1] = sampMap1;
}
Will this program cause any memory leak?
As we are assigning( over writing ) sampMap1 to tempMap[1], will the tempMap loose the reference of sampMap and produce any memory leak?
#include <map>
using namespace std;
int main()
{
map < int , string > sampMap;
map < int , string > sampMap1;
sampMap[1] = "Adams";
sampMap[2] = "Peter";
map < int , map< int , string >> tempMap;
tempMap[1] = sampMap;
sampMap1 = tempMap[1];
sampMap1[3] = "Thomson";
tempMap[1] = sampMap1;
}
Will this program cause any memory leak?
As we are assigning( over writing ) sampMap1 to tempMap[1], will the tempMap loose the reference of sampMap and produce any memory leak?