Salve ragazzi, ho il seguente codice:
Non riesco a passare la funzione "SumKey" a "Sum_After_Level_k".codice:/* sommo le chiavi */ int sumKey(tree *root, int sum){ if( root == NULL ){ return sum; } else { sumKey(root->left); sum=sum+root->info; sumKey(root->right); sum=sum+root->info; } } /* foo */ int Sum_After_Level_k(tree *root, int levels, int k, int sum){ if ( levels < k ){ Sum_After_Level_k(root->left, levels+1, k, sum); Sum_After_Level_k(root->right, levels+1, k, sum); } else { SumKey(root, sum); Sum_After_Level_k=SumKey(root, sum); } }
Il compilatore mi dà questi errori:
Come faccio a passare la function "SumKey" come parametro di input alla function "Sum_After_Level_k"???codice:Compiling: C:\Users\Gaten\Desktop\Untitled1.cpp C:\Users\Gaten\Desktop\Untitled1.cpp: In function 'int sumKey(tree*, int)': C:\Users\Gaten\Desktop\Untitled1.cpp:92: error: too few arguments to function 'int sumKey(tree*, int)' C:\Users\Gaten\Desktop\Untitled1.cpp:96: error: at this point in file C:\Users\Gaten\Desktop\Untitled1.cpp:92: error: too few arguments to function 'int sumKey(tree*, int)' C:\Users\Gaten\Desktop\Untitled1.cpp:98: error: at this point in file C:\Users\Gaten\Desktop\Untitled1.cpp: In function 'int Sum_After_Level_k(tree*, int, int, int)': C:\Users\Gaten\Desktop\Untitled1.cpp:110: error: 'SumKey' was not declared in this scope Process terminated with status 1 (0 minutes, 0 seconds) 5 errors, 0 warnings
Grazie anticipatamente.

Rispondi quotando