直接看实例
代码如下(示例):
#include<iostream>
#include<queue>
using namespace std;
template<class T>
class nod {
public:
nod(T val,nod* left,nod* ight):val(val),left(left),right(right){}
T val;
nod* left;
nod* right;
};
template <typename T>
void dfs(T root) {
queue<T> q;
q.push(root);
while (!q.empty()) {
}
}
int main() {
nod<int>* root = new nod<int>(3,nullptr,nullptr);
dfs(root);
}