Language: C++

#include<iostream>
#include<vector>
#include <iterator>
static const int NIL = -1;
static const int NumberChild = 2;
class Tree {
private:
	int id;
	int parent;
	int child[NumberChild];

public:
	Tree() {
		id = child[0] = child[1] = parent = NIL;
	}
	void AddParent(int ID) {
		parent = ID;
		return;
	}
	void AddID(int ID) {
		id = ID;
		return;
	}
	void AddChild(std::vector<int>&Child) {
		for (unsigned int i = 0; i < Child.size(); ++i) {
			child[i] = Child[i];

		}

		return;
	}
	int GetRoot(std::vector<Tree> nodes, int ID) {
		int RootID = ID;
		if (RootID != NIL&&nodes[RootID].parent != NIL) {
			RootID = GetRoot(nodes, nodes[RootID].parent);
		}
		return RootID;
	}
	void PreorderTreeWalk(std::vector<Tree> nodes, int ID) {
		if (ID != NIL) {
			std::cout << " " << nodes[ID].id;
			PreorderTreeWalk(nodes, nodes[ID].child[0]);
			PreorderTreeWalk(nodes, nodes[ID].child[1]);
		}

		return;
	}
	void InorderTreeWalk(std::vector<Tree> nodes, int ID) {
		if (ID != NIL) {
			InorderTreeWalk(nodes, nodes[ID].child[0]);
			std::cout << " " << nodes[ID].id;
			InorderTreeWalk(nodes, nodes[ID].child[1]);
		}

		return;
	}
	void PostorderTreeWalk(std::vector<Tree> nodes, int ID) {
		if (ID != NIL) {

			PostorderTreeWalk(nodes, nodes[ID].child[0]);
			PostorderTreeWalk(nodes, nodes[ID].child[1]);
			if(nodes[ID].id!=NIL)std::cout << " " << nodes[ID].id;
		}

		return;
	}
	void Reconstruct(const std::vector<int>Pre, const std::vector<int>In, std::vector<Tree> &nodes, const int Root,int &cnt) {
		
		int m = std::distance(In.begin(), std::find(In.begin(), In.end(), Root));
	
		//nodes[cnt].AddID(Root);
		nodes[Root].AddID(Root);
		if (m == 0||Root==NIL) { return; }
		std::vector<int>PreLeft;
	
		std::copy(&Pre[1], &Pre[m]+1, std::back_inserter(PreLeft));
		
		std::vector<int>PreRight;
		
		std::copy(&Pre[m+1 ], &Pre[Pre.size()-1]+1, std::back_inserter(PreRight));
		
		std::vector<int>InLeft;
		std::copy(&In[0], &In[m-1]+1, std::back_inserter(InLeft));
		

		std::vector<int>InRight;
		std::copy(&In[m]+1, &In[In.size() - 1]+1, std::back_inserter(InRight));
		

		std::vector<int>child{ PreLeft.empty() ? NIL : PreLeft[0], PreRight.empty() ? NIL : PreRight[0] };
		//nodes[cnt].AddChild(child);
		nodes[Root].AddChild(child);
		for (unsigned int i = 0; i < child.size(); ++i) {

			nodes[child[i]].AddParent(Root);
		}
		Reconstruct(PreLeft, InLeft, nodes, PreLeft[0], ++cnt);
		Reconstruct(PreRight, InRight, nodes, PreRight[0], ++cnt);
	}
};

void SetVector(std::vector<int>&InputVector) {
	for (unsigned int i = 0; i < InputVector.size(); ++i) {
		std::cin >> InputVector[i];
	}
	return;
}
int main(void) {

	int n;
	std::cin >> n;
	std::vector<int>Pre(n);
	std::vector<int>In(n);
	SetVector(Pre);
	SetVector(In);
	std::vector<Tree> nodes(n+1);
	//ReconstructWithNoParent
	int cnt = 0;
	nodes[1].Reconstruct(Pre, In, nodes, Pre[0],cnt);

	nodes[1].PostorderTreeWalk(nodes, 1);
	std::cout << std::endl;
	//system("pause");
	return 0;
}

Compiler output:
a.cc: In member function 'void Tree::Reconstruct(std::vector<int>, std::vector<int>, std::vector<Tree>&, int, int&)':
a.cc:69:60: error: no matching function for call to 'find(std::vector<int>::const_iterator, std::vector<int>::const_iterator, const int&)'
   69 |                 int m = std::distance(In.begin(), std::find(In.begin(), In.end(), Root));
      |                                                   ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:69:60: note:   '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   69 |                 int m = std::distance(In.begin(), std::find(In.begin(), In.end(), Root));
      |                                                   ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~