![](/img/trans.png)
[英]How to fix 'there are no arguments to 'glGenVertexArrays' that depend on a template parameter …' error in c++
[英]C++ Error: "There are no arguments to 'setw' that depend on a template parameter
这是代码:
template <class TYPE, class KTYPE>
void AvlTree<TYPE, KTYPE> :: _print (NODE<TYPE> *root, int level)
{
int i;
if (root)
{
_print ( root->right, level + 1 );
cout << "bal " << setw(3) << root->bal
<< ": Level " << setw(3) << level;
for (i = 0; i <= level; i++ )
cout << "....";
cout << setw(3) << root->data.key;
if (root->bal == LH)
cout << " (LH)\n";
else if (root->bal == RH)
cout << " (RH)\n";
else
cout << " (EH)\n";
_print ( root->left, level + 1 );
}
}
这是驱动程序即时通讯使用:
AvlTree<node, int> tree;
if (tree.AVL_Empty())
cout << "tree is empty\n";
node newItem;
newItem.word = "ryan";
newItem.key = 1;
tree.AVL_Insert(newItem);
tree.AVL_Print();
return 0;
我得到的错误是:
error: there are no arguments to 'setw' that depend on a template parameter, so a declaration of 'setw' must be available [-fpermissive]
error: 'setw' was not declared in this scope
我尝试使用“ this->”作为其他类似的问题,但是没有运气。 错误消失了,但被以下错误代替:
error: 'class AvlTree<node, int>' has no member named 'setw'
问题是您不包含<iomanip>
。 您需要包括该头文件,因为这实际上是声明std::setw
。
请注意,编译器错误非常清楚: 'setw' was not declared in this scope
。 它告诉您它不知道setw
是什么。 由于setw
来自<iomanip>
标头,因此您需要包括该标头,以便正确告知编译器并知道setw
是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.