I can't get rid this error
IntelliSense: cannot open source file "stdafx.h"
error C1083: Cannot open include file: 'stdafx.h': No such file or directory
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
using namespace std;
//class BinarySearch Tree
class BinarySearchTree
{
private:
struct BST
{
BST* left;
BST* right;
int data;
};
BST* root;
//constructor
public:
BinarySearchTree()
{
root =NULL;
}
//prototypes
bool isEmpty() const {return root == NULL;}
void print_inorder();
void inorder(BST*);
void insert(int);
void search(int);
};
void BinarySearchTree :: search(int d)
{
bool found = false;
if(isEmpty())
{
cout << "This tree is empty!" << endl;
return;
}
BST* curr;
BST* parent;
curr = root;
while (curr != NULL)
{
if(curr -> data ==d)
{
found = true;
break;
}
else
{
parent = curr;
if(d> curr -> data) curr = curr -> right;
else curr = curr -> left;
}
}
if (!found)
{
cout <<"Data not found! " << endl;
}
else
cout << "Element " << d << " is found " << endl;
}
//place small values in left and larger values in right side
//larger elements go right
void BinarySearchTree :: insert(int d)
{
BST* t = new BST;
BST* parent;
t-> data = d;
t->left = NULL;
t->right = NULL;
//is this a new tree?
if(isEmpty()) root = t;
else
{
//Note : all insertions are as leaf noods
BST* curr;
curr = root;
//Find the Node's parent
while(curr)
{
parent = curr;
if(t-> data > curr ->data) curr = curr ->right;
else curr = curr ->left;
}
if(t -> data < parent -> data)
parent -> left = t;
else
parent -> right = t;
cout << "Element " << d << " is inserted into tree " << endl;
}
}
//to display inorder
void BinarySearchTree :: inorder(BST* p)
{
if( p != NULL)
{
if(p->left) inorder (p ->left);
cout << " " << p -> data << " ";
if(p->right) inorder (p -> right);
}
else return;
}
//main function to drivem the above class
int main ()
{
BinarySearchTree bst;
int ch, insert, element;
while(1)
{
//ask user to enter choice
cout << endl << endl;
cout << "Simple Binary Search Tree Operations" << endl;
cout << "------------------------------------ " << endl;
cout << "1. insertion / Creation " << endl;
cout << "2. Search " << endl;
cout << "3. In-Order Traversal" << endl;
cout << "4. Exit" << endl;
cout << "Enter your choice: ";
cin >> ch;
//based on the chioce control the flow of execution.
switch (ch)
{
case 1 : cout << "Enter Number to be inserted: ";
cin >> insert;
bst.insert(insert);
break;
case 3: cout << endl;
cout << "In-Order Traversal" << endl;
cout << "--------------------" << endl;
bst.print_inorder();
break;
case 2: cout << endl;
cout << "Enter Number to be search " << endl;
cin >> element;
bst.search(element);
break;
case 4: system("pause");
return 0;
break;
}//end of switch
}//end of while
}//endl of main