what all do i have to do to make this work... this is my class and functions... and the errors are at the bottom...
do i have to overload operators or is there a much easier way? thanks.
and i know the return function isnt written yet.
#include <iostream>
#include <cstdlib>
using namespace std;
class binaryTree {
public:
binaryTree ();
int menu ();
private:
typedef struct dataNode {
char arriveCity[30];
char departCity[30];
int totalPassengers;
int passengers;
int flightNumber;
struct dataNode * left;
struct dataNode * right;
};
dataNode * root;
bool insert (dataNode *&, dataNode &);
bool search (dataNode *, dataNode &);
bool retrieve (dataNode *, dataNode &);
void inorder (dataNode *);
};
binaryTree::binaryTree() {
dataNode * root = NULL;
dataNode * left = NULL;
dataNode * right = NULL;
}
bool binaryTree::insert(dataNode*& tree, dataNode &flightNumber) {
if (tree == NULL) {
tree = new dataNode;
tree -> left = NULL;
tree -> right = NULL;
tree -> flightNumber = flightNumber;
return true;
}
else if (flightNumber == tree -> flightNumber)
return false;
else if (flightNumber <= tree -> flightNumber)
return insert (tree -> left, flightNumber);
else
return insert (tree -> right, flightNumber);
}
bool binaryTree::search(dataNode * tree, dataNode &flightNumber) {
if (tree == NULL)
return false;
else if (flightNumber == tree -> flightNumber)
return true;
else if (flightNumber <= tree -> flightNumber)
return search (tree -> left, flightNumber);
else
return search (tree -> right, flightNumber);
}
bool binaryTree::retrieve (dataNode * tree, dataNode &flightNumber) {
}
void binaryTree::inorder (dataNode * tree) {
if (tree != NULL) {
inorder (tree -> left);
cout << tree->flightNumber << endl;
inorder (tree -> right);
}
}
int binaryTree::menu () {
int choice;
cout << endl;
cout << "Welcome to the JHD International Airport! How can we be of assistance?" << endl;
cout << "Please select the best option for you:" << endl;
cout << " 1. Create a new flight record." << endl;
cout << " 2. Search for a flight." << endl;
cout << " 3. End current program session." << endl;
cin >> choice;
cout << endl;
if (choice == 2) {
cout << "Please select the search option of your choice:" << endl;
cout << " 1. Display all flight records." << endl;
cout << " 2. Display all departing flights from a city." << endl;
cout << " 3. Display all open flights." << endl;
cout << " 4. Go back to the main menu." << endl;
cin >> choice;
cout << endl;
}
return choice;
}
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp: In member
function `bool binaryTree::insert(binaryTree::dataNode*&,
binaryTree::dataNode&)':
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp:49: error: cannot
convert `binaryTree::dataNode' to `int' in assignment
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp:53: error: no
match for 'operator==' in 'flightNumber ==
tree->binaryTree::dataNode::flightNumber'
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp:55: error: no
match for 'operator<=' in 'flightNumber <=
tree->binaryTree::dataNode::flightNumber'
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp: In member
function `bool binaryTree::search(binaryTree::dataNode*,
binaryTree::dataNode&)':
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp:65: error: no
match for 'operator==' in 'flightNumber ==
tree->binaryTree::dataNode::flightNumber'
C:/Documents and Settings/Josh/Desktop/JHD-cs111project6.cpp:67: error: no
match for 'operator<=' in 'flightNumber <=
tree->binaryTree::dataNode::flightNumber'