Binary Search Trees (BSTs) are fundamental data structures in computer science, offering efficient search, insertion, and deletion operations. In C++, we can easily implement a BST to leverage its benefits. Let's explore a basic C++ example of a Binary Search Tree.

First, we'll define a Node class to represent each tree node, which will contain a data value and pointers to its left and right children. Then, we'll create a BinarySearchTree class with methods for inserting nodes, searching for values, and displaying the tree in-order.

BinarySearchTree Class Implementation
The BinarySearchTree class will have a private Node pointer as its member to represent the root of the tree. It will also have public methods for insert(), search(), and inOrderDisplay().

The Node class will have a data member (int) and two smart pointer members (unique_ptr
Node Class Definition

Here's the definition of the Node class:
```cpp
struct Node {
int data;
unique_ptrBinarySearchTree Class Definition
Now, let's define the BinarySearchTree class with its constructor and methods:

```cpp
class BinarySearchTree {
private:
unique_ptr The insert() method uses recursion to find the correct position to insert a new node. The search() method also uses recursion to determine if a value exists in the tree. The inOrderDisplay() method is a traversal algorithm that visits nodes in ascending order.
Implementing Helper Functions
Now, let's implement the private helper functions for insert(), search(), and inOrderDisplay().

insert() Function Implementation
Here's how the insert() function works:


















```cpp
void BinarySearchTree::insert(Node*& node, int val) {
if (node == nullptr) {
node = make_uniquesearch() Function Implementation
Here's the implementation of the search() function:
```cpp bool BinarySearchTree::search(Node* node, int val) { if (node == nullptr) { return false; } else if (val == node->data) { return true; } else if (val < node->data) { return search(node->left, val); } else { return search(node->right, val); } } ```
inOrderDisplay() Function Implementation
Finally, let's implement the inOrderDisplay() function for traversing and displaying the tree's nodes in ascending order:
```cpp void BinarySearchTree::inOrderDisplay(Node* node) { if (node != nullptr) { inOrderDisplay(node->left); cout << node->data << " "; inOrderDisplay(node->right); } } ```
With these implementations, you can now create a BinarySearchTree object and use its methods to insert values, search for values, and display the tree's contents in-order:
```cpp int main() { BinarySearchTree bst; bst.insert(50); bst.insert(30); bst.insert(20); bst.insert(40); bst.insert(70); bst.insert(60); bst.insert(80); cout << "In-order traversal: "; bst.inOrderDisplay(); cout << "\nSearch 40: " << (bst.search(40) ? "Found" : "Not Found") << endl; cout << "Search 90: " << (bst.search(90) ? "Found" : "Not Found") << endl; return 0; } ```
The output of this code will be:
```cpp In-order traversal: 20 30 40 50 60 70 80 Search 40: Found Search 90: Not Found ```
This Binary Search Tree example in C++ demonstrates a simple and efficient data structure for organizing and operating on data. To further explore BSTs, consider studying balanced search trees, tree rotations, and more advanced applications like AVL trees and red-black trees.