#include <iostream>
using namespace std;
// structs/Classes
/*********************************************************************/
struct Key {
char* data; // string
Key () {this->data = NULL;}
Key(char* data) { this->data = new char[strlen(data)];
strcpy(this->data,data);}
bool operator== (Key& key) { return 0 == strcmp(this->data,key.data);} // is this == to that key
bool operator< (Key& key) { return -1 == strcmp(this->data,key.data);}// is this < that key
bool operator> (Key& key) { return 1 == strcmp(this->data,key.data);} // is this > that key
void print() { cout << data << endl; }
void setData(char* data);
};
void Key::setData(char* data) {
if (data != NULL) { delete data;}
this->data = new char[strlen(data)];
strcpy(this->data,data);
}
/*********************************************************************/
class BST_Node {
private:
Key key; // key holds the data
BST_Node* left; // ptr to left subtree
BST_Node* right; // ptr to right subtree
 
public:
// Managers
BST_Node(); //default constructor
BST_Node(Key key); // Construct given key-data
BST_Node(BST_Node& node); // Copy Constructor
~BST_Node(); // Destruct node
// Operators
BST_Node& operator= (BST_Node& node); // Assignment
// Accessors
Key getKey() {return key;} // get Key Data
BST_Node*& getLeft() {return left;} // get root of left subtree
BST_Node*& getRight() {return right;} // get root of right subtree
};
BST_Node::BST_Node() {
left = NULL;
right = NULL;
}
BST_Node::BST_Node(Key key) { // Construct given key-data
this->key = key;
left = NULL;
right = NULL;
}
BST_Node::BST_Node(BST_Node& node) { // Copy Constructor
this->key = node.key;
left = NULL;
right = NULL;
}
BST_Node::~BST_Node(){ // Destruct node
// BST will handle deletions
//delete left;
//delete right;
}
// Operators
BST_Node& BST_Node::operator= (BST_Node& node) { // Assignment
this->key = node.key;
left = node.left;
right = node.right;
 
return *this;
}
 
/*********************************************************************/
class BST {
private:
BST_Node* root; // root of tree
int size; // number of elements in tree
// Mutators - called by public methods
bool insert(BST_Node* &subRoot, BST_Node* &node); // insert to subtree (recursive)
void preOrder(BST_Node* subRoot); // preOrder-Traversal of tree (recursive)
void inOrder(BST_Node* subRoot); // inOrder-Traversal of tree (recursive)
void postOrder(BST_Node* subRoot); // postOrder-Traversal of tree (recursive)
public:
// Managers
BST(); // Construct Empty Tree
BST(BST& bst); // Copy Constructor
~BST(); // Destruct tree
 
// Operators
BST& operator= (BST& bst); // Assignment 
// Accessors
int getSize(); // returns number of elements in tree
bool empty(); // is tree empty?
bool full(); // is memory available?
void preOrder(); // preOrder-Traversal of tree (recursive)
void inOrder(); // inOrder-Traversal of tree (recursive)
void postOrder(); // postOrder-Traversal of tree (recursive)
bool findKey(); // take input from user-keyboard
bool findKey(Key key, BST_Node* &parent, BST_Node* &foundNode); // given key-data, find node
bool findKey(Key key);
 
// Mutators
bool insert(); // take input from user-keyboard
bool insert(Key key); // insert key-data into tree
bool delNode(); // take input from user-keyboard
bool delNode(Key key); // delete node containing key-data from tree
void destroySubTree(BST_Node* subRoot); 
};
 
BST::BST() { //construct empty tree
root=NULL;
size=0;
}
 
BST::BST(BST& bst) { //copy constructor
root = bst.root;
size = bst.size;
}
 
BST::~BST() { //destruct tree
delete root->getLeft();
delete root->getRight();
}
 
int BST::getSize() { //returns number of elements in tree
return size;
}
 
bool BST::empty() { //is tree empty?
return !size; //or return root==NULL;
}
 
bool BST::full() { //is memory available?
BST_Node* value = new BST_Node;
if (value) {
delete value;
return true;
}
else {
return false;
}
}
 
void BST::preOrder() { // preOrder-Traversal of tree (recursive)
//print header for preorder listing
cout << "Preorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
preOrder(root);
cout << endl << endl;
}
void BST::preOrder(BST_Node* subRoot) {
//base case
if (subRoot == NULL)
return;
//rec case
//process
subRoot->getKey().print();
//go left
preOrder(subRoot->getLeft());
//go right
preOrder(subRoot->getRight());
}
void BST::inOrder() { // inOrder-Traversal of tree (recursive)
//print header for inOrder listing
cout << "Inorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
inOrder(root);
cout << endl << endl;
}
void BST::inOrder(BST_Node* subRoot) { // inOrder-Traversal of tree (recursive)
//base case
if (subRoot == NULL)
return;
//rec case
//go right
inOrder(subRoot->getLeft());
//go left
//process
subRoot->getKey().print();
inOrder(subRoot->getRight());
}
void BST::postOrder() { // postOrder-Traversal of tree (recursive)
//print header for postOrder listing
cout << "Postorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
postOrder(root);
cout << endl << endl;
}
void BST::postOrder(BST_Node* subRoot) { // postOrder-Traversal of tree (recursive)
//base case
if (subRoot == NULL)
return;
//rec case
 
//go right
postOrder(subRoot->getRight());
//go left
postOrder(subRoot->getLeft());
//process
subRoot->getKey().print();
}
bool BST::findKey() {
Key key;
cout << "What would you like to find" << endl;
cin >> key.data;
return findKey(key); 
}
bool BST::findKey(Key key) {
if(root == NULL)
return false;
return findKey(key, root, foundNode);
}
bool findKey(Key key, BST_Node* &parent, BST_Node* &foundNode) {
if(foundNode == NULL)
return false;
else if(key.data == foundNode->getKey().data)
return true;
else if(key.data < foundNode->getKey().data) {
return findKey(key, foundNode->getLeft());
 
}
else if(key.data > foundNode->getKey().data) {
return findKey(key, foundNode->getRight());
}
else
return false;
}
bool BST::insert() { // take input from user-keyboard
char* string = new char[20];
// prompt & input string
cout << "Enter a value: ";
cin >> string;
 
Key key(string);
return insert(key);
}
bool BST::insert(Key key) { // insert key-data into tree
BST_Node* node = new BST_Node(key);
return insert(root,node);
}
bool BST::insert(BST_Node* &subRoot, BST_Node* &node) { // insert to subtree (recursive)
//root = new BST_Node;
if (!subRoot) {
subRoot = node;
return true;
}
else if(subRoot->getKey() == node->getKey()){ //already there 
cout << "Duplicate \n"; 
return false; 
}
else if(subRoot->getKey() > node->getKey()) { //go left
return insert(subRoot->getLeft(), node);
}
else if(subRoot->getKey() < node->getKey()) { //go right
return insert(subRoot->getRight(), node);
}
}
bool BST::delNode() {
Key key;
cout << "What do you want to delete?" << endl;
cin >> key.data;
return delNode(key);
}
bool BST::delNode(Key key) {
BST_Node* node = root;
if(findKey(key,root)) {
if(root == NULL)
return false;
if(root->getLeft() == NULL) {
root = root->getRight();
delete node;
return false;
}
else if(root->getRight() == NULL) {
root = root->getLeft();
delete node;
return false;
}
else {
node = root->getLeft();
while(node->getRight() != NULL)
node = node->getRight();
return true;
}
root->getKey() = node->getKey();
delNode(key);
}
else 
return false;
}
 
void destroySubTree(BST_Node* subRoot) {
return;
}
/*********************************************************************/
void main () {
// Example of Key - delete this when understood
Key k("Paul"), k2("Sue");
cout << k.data << ' ' << k2.data << endl;
BST bst;
bst.insert();
bst.insert();
bst.insert();
bst.insert();
bst.preOrder();
bst.postOrder();
bst.inOrder();
}

i get the following errors and i'm lost with how to fix them

--------------------Configuration: bst - Win32 Debug--------------------
Compiling...
bst.cpp
error C2065: 'foundNode' : undeclared identifier
error C2660: 'findKey' : function does not take 2 parameters
error C2660: 'findKey' : function does not take 2 parameters
error C2661: 'findKey' : no overloaded function takes 2 parameters

Well, the errors seem rather clear.
You're calling your findKey method with an illegal signature.
And you never declared a variable "foundNode" before using it.

Well, the errors seem rather clear.
You're calling your findKey method with an illegal signature.
And you never declared a variable "foundNode" before using it.

i tried declaring it a few times and still got the error. i dont know what im suppose to do cause things i tried failed thats why i gave up and my friend referred me to here to post it

All your problems are solely related to the findKey( ) method. You have overloaded the findKey( ) to work with three different types of parameter sets but using it in wrong manner.

See the comments marked in red by me in your code.

Key key; // key holds the data
BST_Node* left; // ptr to left subtree
BST_Node* right; // ptr to right subtree
 
public:
// Managers
BST_Node(); //default constructor
BST_Node(Key key); // Construct given key-data
BST_Node(BST_Node& node); // Copy Constructor
~BST_Node(); // Destruct node
// Operators
BST_Node& operator= (BST_Node& node); // Assignment
// Accessors
Key getKey() {return key;} // get Key Data
BST_Node*& getLeft() {return left;} // get root of left subtree
BST_Node*& getRight() {return right;} // get root of right subtree
};
BST_Node::BST_Node() {
left = NULL;
right = NULL;
}
BST_Node::BST_Node(Key key) { // Construct given key-data
this->key = key;
left = NULL;
right = NULL;
}
BST_Node::BST_Node(BST_Node& node) { // Copy Constructor
this->key = node.key;
left = NULL;
right = NULL;
}
BST_Node::~BST_Node(){ // Destruct node
// BST will handle deletions
//delete left;
//delete right;
}
// Operators
BST_Node& BST_Node::operator= (BST_Node& node) { // Assignment
this->key = node.key;
left = node.left;
right = node.right;
 
return *this;
}
 
/*********************************************************************/
class BST {
private:
BST_Node* root; // root of tree
int size; // number of elements in tree
// Mutators - called by public methods
bool insert(BST_Node* &subRoot, BST_Node* &node); // insert to subtree (recursive)
void preOrder(BST_Node* subRoot); // preOrder-Traversal of tree (recursive)
void inOrder(BST_Node* subRoot); // inOrder-Traversal of tree (recursive)
void postOrder(BST_Node* subRoot); // postOrder-Traversal of tree (recursive)
public:
// Managers
BST(); // Construct Empty Tree
BST(BST& bst); // Copy Constructor
~BST(); // Destruct tree
 
// Operators
BST& operator= (BST& bst); // Assignment 
// Accessors
int getSize(); // returns number of elements in tree
bool empty(); // is tree empty?
bool full(); // is memory available?
void preOrder(); // preOrder-Traversal of tree (recursive)
void inOrder(); // inOrder-Traversal of tree (recursive)
void postOrder(); // postOrder-Traversal of tree (recursive)
bool findKey(); // take input from user-keyboard
bool findKey(Key key, BST_Node* &parent, BST_Node* &foundNode); // given key-data, find node
bool findKey(Key key);
 
// Mutators
bool insert(); // take input from user-keyboard
bool insert(Key key); // insert key-data into tree
bool delNode(); // take input from user-keyboard
bool delNode(Key key); // delete node containing key-data from tree
void destroySubTree(BST_Node* subRoot); 
};
 
BST::BST() { //construct empty tree
root=NULL;
size=0;
}
 
BST::BST(BST& bst) { //copy constructor
root = bst.root;
size = bst.size;
}
 
BST::~BST() { //destruct tree
delete root->getLeft();
delete root->getRight();
}
 
int BST::getSize() { //returns number of elements in tree
return size;
}
 
bool BST::empty() { //is tree empty?
return !size; //or return root==NULL;
}
 
bool BST::full() { //is memory available?
BST_Node* value = new BST_Node;
if (value) {
delete value;
return true;
}
else {
return false;
}
}
 
void BST::preOrder() { // preOrder-Traversal of tree (recursive)
//print header for preorder listing
cout << "Preorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
preOrder(root);
cout << endl << endl;
}
void BST::preOrder(BST_Node* subRoot) {
//base case
if (subRoot == NULL)
return;
//rec case
//process
subRoot->getKey().print();
//go left
preOrder(subRoot->getLeft());
//go right
preOrder(subRoot->getRight());
}
void BST::inOrder() { // inOrder-Traversal of tree (recursive)
//print header for inOrder listing
cout << "Inorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
inOrder(root);
cout << endl << endl;
}
void BST::inOrder(BST_Node* subRoot) { // inOrder-Traversal of tree (recursive)
//base case
if (subRoot == NULL)
return;
//rec case
//go right
inOrder(subRoot->getLeft());
//go left
//process
subRoot->getKey().print();
inOrder(subRoot->getRight());
}
void BST::postOrder() { // postOrder-Traversal of tree (recursive)
//print header for postOrder listing
cout << "Postorder Listing" << endl;
if (!root)
cout<<"tree is empty"<<endl;
postOrder(root);
cout << endl << endl;
}
void BST::postOrder(BST_Node* subRoot) { // postOrder-Traversal of tree (recursive)
//base case
if (subRoot == NULL)
return;
//rec case
 
//go right
postOrder(subRoot->getRight());
//go left
postOrder(subRoot->getLeft());
//process
subRoot->getKey().print();
}
bool BST::findKey() {
Key key;
cout << "What would you like to find" << endl;
cin >> key.data;
return findKey(key); 
}
bool BST::findKey(Key key) {
if(root == NULL)
return false;
return findKey(key, root, foundNode);
// how do you expect to use foundNode when you havent declared it ?
}

// here you are missing class name

bool BST::findKey(Key key, BST_Node* &parent, BST_Node* &foundNode) {
if(foundNode == NULL)
return false;
else if(key.data == foundNode->getKey().data)
return true;
else if(key.data < foundNode->getKey().data) {

// there is no findkey function which takes 2 parameters
return findKey(key, foundNode->getLeft());
 
}
else if(key.data > foundNode->getKey().data) {

// there is no findkey function which takes 2 parameters return findKey(key, foundNode->getRight());
}
else
return false;
}
bool BST::insert() { // take input from user-keyboard
char* string = new char[20];
// prompt & input string
cout << "Enter a value: ";
cin >> string;
 
Key key(string);
return insert(key);
}
bool BST::insert(Key key) { // insert key-data into tree
BST_Node* node = new BST_Node(key);
return insert(root,node);
}
bool BST::insert(BST_Node* &subRoot, BST_Node* &node) { // insert to subtree (recursive)
//root = new BST_Node;
if (!subRoot) {
subRoot = node;
return true;
}
else if(subRoot->getKey() == node->getKey()){ //already there 
cout << "Duplicate \n"; 
return false; 
}
else if(subRoot->getKey() > node->getKey()) { //go left
return insert(subRoot->getLeft(), node);
}
else if(subRoot->getKey() < node->getKey()) { //go right
return insert(subRoot->getRight(), node);
}
}
bool BST::delNode() {
Key key;
cout << "What do you want to delete?" << endl;
cin >> key.data;
return delNode(key);
}
bool BST::delNode(Key key) {
BST_Node* node = root;
if(findKey(key,root)) {
if(root == NULL)
return false;
if(root->getLeft() == NULL) {
root = root->getRight();
delete node;
return false;
}
else if(root->getRight() == NULL) {
root = root->getLeft();
delete node;
return false;
}
else {
node = root->getLeft();
while(node->getRight() != NULL)
node = node->getRight();
return true;
}
root->getKey() = node->getKey();
delNode(key);
}
else 
return false;
}
 
void destroySubTree(BST_Node* subRoot) {
return;
}
/*********************************************************************/
// main returns int and not void
void main () {
// Example of Key - delete this when understood
Key k("Paul"), k2("Sue");
cout << k.data << ' ' << k2.data << endl;
BST bst;
bst.insert();
bst.insert();
bst.insert();
bst.insert();
bst.preOrder();
bst.postOrder();
bst.inOrder();
}
#include <iostream>
#include <queue>
#include <fstream>
#include <string>
#include <conio.h>

using namespace std;
// structs/Classes
/*********************************************************************/
struct Key {
 char* data;  // string
 Key () {this->data = NULL;}
 Key(char* data) { this->data = new char[strlen(data)];
                strcpy(this->data,data);}
 bool operator== (Key& key) { return 0 == strcmp(this->data,key.data);} // is this == to that key
 bool operator< (Key& key)  { return -1 == strcmp(this->data,key.data);}// is this < that key
 bool operator> (Key& key)  { return 1 == strcmp(this->data,key.data);} // is this > that key
 void print() { cout << data << endl; }
 void setData(char* data);
};
void Key::setData(char* data) {
 if (data != NULL) { delete data;}
 this->data = new char[strlen(data)];
 strcpy(this->data,data);
}
/*********************************************************************/
class BST_Node {
private:
 Key key;         // key holds the data
 BST_Node* left;  // ptr to left subtree
 BST_Node* right; // ptr to right subtree

public:
 // Managers
 BST_Node(); //default constructor
 BST_Node(Key key);        // Construct given key-data
 BST_Node(BST_Node& node); // Copy Constructor
 ~BST_Node();              // Destruct node
 // Operators
 BST_Node& operator= (BST_Node& node); // Assignment
 // Accessors
 Key getKey() {return key;}         // get Key Data
 BST_Node*& getLeft() {return left;}  // get root of left subtree
 BST_Node*& getRight() {return right;} // get root of right subtree
};
BST_Node::BST_Node() {
 left = NULL;
 right = NULL;
}
BST_Node::BST_Node(Key key) {         // Construct given key-data
 this->key = key;
 left = NULL;
 right = NULL;
}
BST_Node::BST_Node(BST_Node& node) {  // Copy Constructor
 this->key = node.key;
 left = NULL;
 right = NULL;
}
BST_Node::~BST_Node(){                // Destruct node
 // BST will handle deletions
 //delete  left;
 //delete  right;
}
// Operators
BST_Node& BST_Node::operator= (BST_Node& node) { // Assignment
 this->key = node.key;
 left = node.left;
 right = node.right;

 return *this;
}
 
/*********************************************************************/
class BST {
private:
 BST_Node* root; // root of tree
 int size;       // number of elements in tree
 // Mutators - called by public methods
 bool insert(BST_Node* &subRoot, BST_Node* &node); // insert to subtree (recursive)
 void preOrder(BST_Node* subRoot);  // preOrder-Traversal of tree (recursive)
 void inOrder(BST_Node* subRoot);   // inOrder-Traversal of tree (recursive)
 void postOrder(BST_Node* subRoot); // postOrder-Traversal of tree (recursive)
public:
 // Managers
 BST();         // Construct Empty Tree
 BST(BST& bst); // Copy Constructor
 ~BST();        // Destruct tree
 
 // Operators
 BST& operator= (BST& bst); // Assignment 
 // Accessors
 int getSize(); // returns number of elements in tree
 bool empty();  // is tree empty?
 bool full();   // is memory available?
 void preOrder();  // preOrder-Traversal of tree (recursive)
 void inOrder();   // inOrder-Traversal of tree (recursive)
 void postOrder(); // postOrder-Traversal of tree (recursive)
 bool findKey();   // take input from user-keyboard
 bool findKey(Key key, /*BST_Node* &parent,*/ BST_Node* &foundNode); // given key-data, find node
 bool findKey(Key key);
 
 // Mutators
 bool insert();         // take input from user-keyboard
 bool insert(Key key);  // insert key-data into tree
 bool delNode();        // take input from user-keyboard
 bool delNode(Key key); // delete node containing key-data from tree
 void destroySubTree(BST_Node* subRoot); 
};
 
BST::BST() { //construct empty tree
 root=NULL;
 size=0;
}

BST::BST(BST& bst) { //copy constructor
 root = bst.root;
 size = bst.size;
}

BST::~BST() { //destruct tree
 delete root->getLeft();
 delete root->getRight();
}

int BST::getSize() { //returns number of elements in tree
 return size;
}

bool BST::empty() { //is tree empty?
 return !size; //or return root==NULL;
}

bool BST::full() { //is memory available?
 BST_Node* value = new BST_Node;
 if (value) {
  delete value;
  return true;
 }
 else {
 return false;
 }
}

void BST::preOrder() {  // preOrder-Traversal of tree (recursive)
 //print header for preorder listing
 cout << "Preorder Listing" << endl;
 if (!root)
  cout<<"tree is empty"<<endl;
 preOrder(root);
 cout << endl << endl;
}
void BST::preOrder(BST_Node* subRoot) {
 //base case
 if (subRoot == NULL)
  return;
 //rec case
 //process
 subRoot->getKey().print();
 //go left
 preOrder(subRoot->getLeft());
 //go right
 preOrder(subRoot->getRight());
}
void BST::inOrder() {   // inOrder-Traversal of tree (recursive)
 //print header for inOrder listing
 cout << "Inorder Listing" << endl;
 if (!root)
  cout<<"tree is empty"<<endl;
 inOrder(root);
 cout << endl << endl;
}
void BST::inOrder(BST_Node* subRoot) {   // inOrder-Traversal of tree (recursive)
 //base case
 if (subRoot == NULL)
  return;
 //rec case
 //go left
 inOrder(subRoot->getLeft());
 //process
 subRoot->getKey().print();
        //go right
 inOrder(subRoot->getRight());
}
void BST::postOrder() { // postOrder-Traversal of tree (recursive)
 //print header for postOrder listing
 cout << "Postorder Listing" << endl;
 if (!root)
  cout<<"tree is empty"<<endl;
 postOrder(root);
 cout << endl << endl;
}
void BST::postOrder(BST_Node* subRoot) { // postOrder-Traversal of tree (recursive)
 //base case
 if (subRoot == NULL)
  return;
 //rec case
 
 //go left
 postOrder(subRoot->getLeft());
 //go right
 postOrder(subRoot->getRight());
 //process
 subRoot->getKey().print();
}
bool BST::findKey() {
 Key key;
 cout << "What would you like to find" << endl;
 cin >> key.data;
 return findKey(key); 
}
bool BST::findKey(Key key)  {
 if(root == NULL)
  return false;
 return findKey(key, /*root,*/ root);
}
bool findKey(Key key, /*BST_Node* &parent,*/ BST_Node* &foundNode) {
 if(foundNode == NULL)
  return false;
 else if(key.data == foundNode->getKey().data)
   return true;
 else if(key.data < foundNode->getKey().data) {
  return findKey(key, foundNode->getLeft());
   
 }
 else if(key.data > foundNode->getKey().data) {
  return findKey(key, foundNode->getRight());
 }
 else
  return false;
}
bool BST::insert() {    // take input from user-keyboard
 char* string = new char[20];
 // prompt & input string
 cout << "Enter a value: ";
 cin  >> string;
 
 Key key(string);
 return insert(key);
}
bool BST::insert(Key key) {  // insert key-data into tree
 BST_Node* node = new BST_Node(key);
 return insert(root,node);
}
bool BST::insert(BST_Node* &subRoot, BST_Node* &node) { // insert to subtree (recursive)
 //root = new BST_Node;
 if (!subRoot) {
  subRoot = node;
  return true;
 }
 else if(subRoot->getKey() == node->getKey()) //already there 
        cout << "Duplicate \n"; 
        return false;
 if(subRoot->getKey() > node->getKey()) //go left
  return insert(subRoot->getLeft(), node);
 else if(subRoot->getKey() < node->getKey()) //go right
  return insert(subRoot->getRight(), node);
}
bool BST::delNode() {
 Key key;
 cout << "What do you want to delete?" << endl;
 cin >> key.data;
 return delNode(key);
}
bool BST::delNode(Key key) {
 BST_Node* node = root;
 if(findKey(key,root)) {
  if(root == NULL)
   return false;
  if(root->getLeft() == NULL) {
   root = root->getRight();
   delete node;
   return false;
  }
  else if(root->getRight() == NULL) {
   root = root->getLeft();
   delete node;
   return false;
  }
  else {
   node = root->getLeft();
   while(node->getRight() != NULL)
    node = node->getRight();
   return true;
  }
  root->getKey() = node->getKey();
  delNode(key);
 }
 else 
  return false;
}

void destroySubTree(BST_Node* subRoot) {
 return;
}
/*********************************************************************/
void main () {
 BST bst;
 bst.insert();
 bst.insert();
 bst.insert();
 bst.insert();
 bst.preOrder();
 bst.postOrder();
 bst.inOrder();
}

i fixed those errors and now it compiles fine. the problem is when i run it, it is suppose to take in values from the user, like "a, b, c, d" then its suppose to print out the preorder, inorder and postrder of that expression but when it prints them out on the screen it only shows the letter "a" for post, in, and pre orders. got any clue why?

One more mistake that I can see in your code is in your constructor:

Key(char* data) { this->data = new char[strlen(data)];

I think you are not leaving off enough space for the null character which is present at the end of C style strings.

For eg. if the string passed is "a+b+c", length is 6 since there is a null character at the end. And your constructor is invoked with something like:
this->data = new char[5] ; // this is wrong

So change that line to

Key(char* data) { this->data = new char[strlen(data) + 1 ];

Make this change, then repost along with a sample run of your program, along with input provided by you, output of the program and the expected output. That way it would be simpler to help you out.

This article has been dead for over six months. Start a new discussion instead.