Expression cannot be evaluated
This is the error I get when in the debugger of VC++, but the program compiles fine. When I run it, there is an immediate error and I have to close the program. Any ideas as to why this is happening?
Code:
Code:
#include <iostream.h>
#include <stdlib.h>
class BTree_Data{
private:
int location, personType;
public:
BTree_Data(){ location = 0; personType = 0; }
~BTree_Data(){}
BTree_Data *rightChild;
BTree_Data *leftChild;
//Methods
void setLocation(int i) { location = i; } //error here
int getLocation(void) { return location; } //here too
void setPersonType(int i) { personType = i; } //and here
int getPersonType(void) { return personType; } //last one
};
void addChild(BTree_Data root, BTree_Data iterator);
void delChild(BTree_Data root, BTree_Data iterator);
void printTree(BTree_Data root, BTree_Data iterator);
int main(void)
{
int choice;
BTree_Data *root = 0, *iterator = 0;
root->setLocation(0);
root->setPersonType(0);
root->rightChild = NULL;
root->leftChild = NULL;
iterator = root;
cout << "Menu:\n" <<
"\t1: Add a child\n" <<
"\t2: Delete a child\n" <<
"\t3: Print tree\n" <<
"\t4: Exit\n\n" <<
"::>";
choice = cin.get();
switch(choice){
case 1:
addChild(*root, *iterator);
break;
case 2:
delChild(*root, *iterator);
break;
case 3:
printTree(*root, *iterator);
break;
case 4:
exit(0);
break;
default:
cout << "Invalid input, please try again\n";
break;
}
return 0;
}
void addChild(BTree_Data root, BTree_Data iterator){
cout << "addChild() Function" << endl;
}
void delChild(BTree_Data root, BTree_Data iterator){
cout << "delChild() Function" << endl;
}
void printTree(BTree_Data root, BTree_Data iterator){
cout << "printTree() Function" << endl;
}