0

For a map,

map<int,pair<int,int>>m;

The below line worked

m[level]=pair<int,int>(h,root->data);       //root is a pointer to a node in tree

But the below didn't

m.insert(pair<int,pair<int,int>>(level,(h,root->data)));

Why?

1 Answers1

0

I suggest adding C++ tag to the thread. Use std::make_pair for making pairs. And it's not really recommended to use using namespace std; Why is “using namespace std;” considered bad practice?

m.insert(std::make_pair(level, std::make_pair(h, root->data)))
pesuww
  • 105
  • 11