I am getting compilation issues for my code:
#include<iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode *left, *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
int main(){
pair <TreeNode, int> temp, node;
return 0;
}
I can't overload the constructor of the structure which doesn't accept any value.
Error:
/usr/include/c++/4.6/bits/stl_pair.h:100:25: error: no matching function for call to ‘TreeNode::TreeNode()’
/usr/include/c++/4.6/bits/stl_pair.h:100:25: note: candidates are:
../a.cpp:18:2: note: TreeNode::TreeNode(int)
../a.cpp:18:2: note: candidate expects 1 argument, 0 provided
../a.cpp:15:8: note: TreeNode::TreeNode(const TreeNode&)
../a.cpp:15:8: note: candidate expects 1 argument, 0 provided
make: *** [102_binary-tree-level-order-traversal.o] Error 1