c++结构体模板

来源:互联网 发布:linux ctrl alt f2 编辑:程序博客网 时间:2024/06/10 18:11

很久以前弄过这个结构体模板,但是一直弄不出来typedef这种写法,书上有没有讲,论坛上也没有人知道,但是今天又遇到了,于是转战overflow去问了,果然解决了,不过就是英文太蹩脚,过程比较费力,这是问题的连接,想看到更多思路的请点击[http://stackoverflow.com/questions/37959171/how-to-fix-it-you-should-typing]


template<class T>struct BiTree{    T data;    BiTree<T> *lchild;    BiTree<T> *rchild;};//******1***********typedef BiTree<int> *PNode;typedef BiTree<int> Node;void main(){<span style="white-space:pre"></span>//使用typedef<span style="white-space:pre"></span>PNode a;<span style="white-space:pre"></span>Node b;<span style="white-space:pre"></span>//未使用typedef<span style="white-space:pre"></span>BiTree<char> one;<span style="white-space:pre"></span>BiTree<char> *POne;<span style="white-space:pre"></span>getchar();}



0 0