fork download
  1. #include <iostream>
  2.  
  3. struct Nodo
  4. {
  5. int value;
  6. Nodo* left, *right;
  7. };
  8.  
  9. void Insert(Nodo *root, int x){
  10. if(root == NULL){
  11. Nodo *n = new Nodo();
  12. n->value = x;
  13. root = n;
  14. return;
  15. }
  16. else{
  17. if(root->value > x)
  18. Insert(&(root)->left, x);
  19. else
  20. Insert(&(root)->right, x);
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. Nodo *root = NULL;
  27. Insert(root, 1);
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void Insert(Nodo*, int)':
prog.cpp:18:36: error: cannot convert 'Nodo**' to 'Nodo*' for argument '1' to 'void Insert(Nodo*, int)'
             Insert(&(root)->left, x);
                                    ^
prog.cpp:20:37: error: cannot convert 'Nodo**' to 'Nodo*' for argument '1' to 'void Insert(Nodo*, int)'
             Insert(&(root)->right, x);
                                     ^
stdout
Standard output is empty