![](/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.