I did it in pure C but now I am trying to implement a binary search tree in C++. Most of the code is the exact same but instead of malloc() I want to use the new operator. However, I am getting this error:
Undefined symbols for architecture x86_64:
  "operator new(unsigned long)", referenced from:
      GetNewNode(int) in BstTreeV3-beb469.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is my code on ideone. Click here to view it.
Node* GetNewNode(int data) {
    Node *newNode = new Node();
    newNode->data = data;
    newNode->left = NULL;
    newNode->right = NULL;
    return newNode;
}
void Insert(Node **root, int data) 
{
    if (*root == NULL) { // empty tree
        *root = GetNewNode(data);
    }
    else if ((*root)->data < data) {
        Insert(&((*root)->left), data);
    }
    else {
        Insert(&((*root)->right), data);
    }
}
I understand this may not be the best implementation method, but I am just practicing. If you have any recommendations on how to implement a BST then please feel free to comment.
 
     
    