Error: template argument uses local type
来源:互联网 发布:macbook 软件下载 编辑:程序博客网 时间:2024/04/30 14:38
请看如下一段代码:
template <class ElemType>void PostOrderTraverse_I(TreeNode<ElemType>* t,void (*Visit)(ElemType& e)){ struct StackNode { TreeNode<ElemType>* ptr; int tag; }; StackNode<ElemType> curnode,topnode; LinkStack<StackNode<ElemType> > S;······}
其中LinkStack是我自己写的链栈类,是一个模板类。上面的这段代码编译出错。提示是这样的:
error: template argument for 'template<class ElemType> class LinkStack'uses local type 'PostOrderTraverse_I(TreeNode<ElemType>*, void (*)(ElemType&)) [with ElemType = char]::StackNode'|
查了资料,才知道在2003 C++ Standard中给出了下面的说法:
A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as atemplate-argument for a templatetype-parameter.
于是,我就把struct StackNode写在了函数PostOrderTraverse_I的外面:
template <class ElemType>struct StackNode{ TreeNode<ElemType>* ptr; int tag;};template <class ElemType>void PostOrderTraverse_I(TreeNode<ElemType>* t,void (*Visit)(ElemType& e)){ StackNode<ElemType> curnode,topnode; LinkStack<StackNode<ElemType> > S;······}
再编译,通过。
- Error: template argument uses local type
- SpringMVC:Name for argument type ERROR
- How to get a type in C++ when its template argument is the argument
- error: '>>' should be '> >' within a nested template argument list
- error:'>>' should be '> >' within a nested template argument list
- linux error: ‘>>’ should be ‘> >’ within a nested template argument list
- error C2079: * uses undefined class 'CArray<TYPE,ARG_TYPE>'
- error C2955: 'std::list' : use of class template requires template argument list
- struts:实现图片的上传 argument type mismatch error
- openCV error: Bad argument (unrecognized or unsupported array type)
- struts:实现图片的上传 argument type mismatch error
- 编译fuse-dfs时“error: type argument ? extends T”错误
- opencv Error:Bad argument <Unknown arrray type> in cvarrTomat
- error: '>>' should be '> >' within a nested template argument list| C++ Dev
- argument type mismatch
- argument type mismatch
- argument type mismatch
- argument type mismatch 解决
- C++虚函数表解析(转) ——写的真不错,忍不住转了
- 用C++实现的一种插件体系结构-----概述
- asp网页自动刷新总结
- hdu 1540 Tunnel Warfare(单点更新,区间合并)
- 大数运算——加法,减法,乘法
- Error: template argument uses local type
- 多线程和多进程的区别
- 机器学习正在改变我们的工作与生活
- Brackets Sequence
- csdn经常卡,在博客园开了博客
- llvm安装过程问题
- 程序语言发展简述
- jquery常用的js
- VIM基本使用方法