模板参数遇到麻烦

时间:2015-05-04 14:12:50

标签: c++ class templates types arguments

这是我的第一个模板,运行此代码时遇到一些错误。任何帮助都会很棒!

success: function(data) {
  $('html').replaceWith(data);
}

错误:"提示"未在此范围内声明            模板参数1无效

1 个答案:

答案 0 :(得分:1)

The template statement applies to the thing that follows it, not to the rest of the file. So as it stands, your polinom is not a template class. Try this:

template <typename Tip>
class polinom;

template <typename Tip>
class node {
  node <Tip>* next;
  Tip coef;
  int grad, nr;
public:
  friend class polinom<Tip>;
};

template <typename Tip>
class polinom
{
protected:
  node<Tip>* prim;
};