Well I am sure that my code is right. but in my main ().. my cout <<myTree casues an issue and I dont know why . any help would be much needed... I am almost there.

Attachments
#include <iostream>
#include <string>
#include "BSTree.h"
#include "Contributor.h"
using namespace std;

void BSTree::insert(Contributor InData)
{
    TreeNode* tNode = new TreeNode;
    TreeNode* parent;
	TreeNode* root = NULL;
    tNode->Data = InData;
    tNode->pLeft = NULL;
    tNode->pRight = NULL;
    parent = NULL;
	/*  is this a new tree?
	if(isEmpty()) root = tNode;
	else
	{*/
	//Note: ALL insertions are as leaf nodes
    TreeNode* current;
    current = root;
    // Find the Node's parent
    while(current)
    {
        parent = current;
        if(tNode->Data > current->Data)
		{
			current = current->pRight;
		}else{
			current = current->pLeft;
		}
    }

    if(tNode->Data < parent->Data)
	{
       parent->pLeft = tNode;
		   cout <<tNode;
	}else{
       parent->pRight = tNode;
			cout<<tNode;
    }
}
#ifndef BSTREE_H
#define BSTREE_H

#include <iostream>
#include <string>
#include "Contributor.h"
using namespace std;

class TreeNode
{
public:
	TreeNode()
		{
			pLeft=pRight = NULL;		   
		}
	TreeNode(Contributor InData)
		{
			pLeft=NULL;
			pRight = NULL;
			Data= InData;
		}
	Contributor Data;   
	TreeNode* pRight;
	TreeNode* pLeft;
	TreeNode* root;
};

class BSTree
{
	public:
        BSTree()
        {
			TreeNode*root = NULL;
        }
     /* bool isEmpty() const { return root==NULL; }
        void print_inorder();
		void print_postorder();
		void print_preorder();*/
  
        void insert(Contributor InData);
        //void remove();

	private:
		/*void inorder(TreeNode * pTree);
		void preorder(TreeNode * pTree);
        void postorder(TreeNode * pTree);*/
};
#endif
//***************************************************************
// TITLE:                      	Contributor	
// FILEInContrib:                   	Contributor.cpp
// PREPARED FOR:               	CS230 Section <section number>
// PROGRAMMER(S):              	< Phillip Harris>
// DEVELOPMENT DATE:           	< 07/09/08>
// COMPILER USED:      		    <MS visual studio 2005>
// TARGET PLATFORM:         	< WIN XP >
//================================================================
//                           PROJECT FILES
//    	contributor.h, contributor.cpp,	Lab1.cpp
//================================================================
//                          REVISION HISTORY
//   DATE     PROGRAMMER            DESCRIPTION OF CHANGES MADE
//	<07/08/08	Phil Harris				Original >
//================================================================

#include <iostream>
#include <string>
#include <iomanip>
#include "Contributor.h"
#include "BSTree.h"
using namespace std;

///c-tor implementation 
 int num =1;
Contributor::Contributor()
{	
	Name = ""; 
	Contribution = 0.0f; 
	Sex = None;
	IDKey = 0; 
}
//copy C-tor
Contributor::Contributor(string InContrib, double InContribution, Gender InSex, int InIDKey)
{
	Name= InContrib;
    Contribution= InContribution;
	Sex = InSex;
    IDKey= InIDKey;
}
Contributor::Contributor(const Contributor &CCContrib)
{ 
	Name = CCContrib.Name;
	Contribution= CCContrib.Contribution;
	Sex = CCContrib.Sex;
	IDKey = CCContrib.IDKey;
}
ostream &operator <<(ostream & Out,Contributor &InContrib)
 	{  
     	//Out<<endl<<num<<"\tName of the Contributor? " <<endl;
		//Out<<"\tName: " <<InContrib.Name <<endl;
		//Out<<"\tID Number: " <<InContrib.IDKey<<endl;
		//Out<<endl<<num<<endl;
        Out<<"\tContribution: "<<InContrib.Contribution<<".00"<<endl;
		Out<<"\tGender: ";	
 			switch (InContrib.Sex)
			{
				case Male: Out<<" Male ";break; 
				case Female: Out<<" Female ";break;
				//default: Out<<"NONE";break;
     		}
  		num++;
		Out<<endl<<endl; 
		return Out; 
	}
/*istream &operator >> (istream &In,Contributor &InContrib)
	{
		int SelSex = 0;//selection of gender
		In.clear();
		In.ignore(In.rdbuf()->in_avail(), '\n'); 
		cout<<"\tEnter Contirbutors Name: ";
		getline(In,InContrib.Name); 

		cout<<"\tEnter the amount of "<<InContrib.Name <<"'s contribution ";
		In>>InContrib.Contribution; 
		
		cout<<"\tNow Enter an ID# for "<<InContrib.Name<<" ";
		In>>InContrib.IDKey;
		
		cout<<"\twhat is "<<InContrib.Name<<"'s Gender? "<<endl;
		cout<<"\t1. Male. \n\t2. Female \n\t3. None\n\n";
		In >> SelSex;
		switch(SelSex)
			{
				case 1: SelSex = Male; break;
				case 2: SelSex = Female; break;
				case 3: SelSex = None; break;
			}
		return In;
	}
	*/
Contributor &Contributor::operator = (const Contributor & RtSide)
{
	if(this != &RtSide)
	{
		//Name = RtSide.Name;
		Contribution = RtSide.Contribution;
		Sex = RtSide.Sex;
		//IDKey = RtSide.IDKey;
	}	
	return *this;
}
bool Contributor::operator <(const Contributor & RtSide)
	{return (Contribution <RtSide.Contribution);}

bool Contributor::operator >(const Contributor & RtSide)
	{return (Contribution <RtSide.Contribution);}	

bool Contributor::operator ==(const Contributor & RtSide)
	{return ((Name == RtSide.Name)&&(Contribution==RtSide.Contribution)&&(Sex== RtSide.Sex));
	}
bool Contributor::operator !=(const Contributor & RtSide)
	{return((Name != RtSide.Name)||(Contribution!=RtSide.Contribution)||(Sex != RtSide.Sex));
	}
// TITLE:                      	Contributor	
// FILENAME:                   	Contributor.h
// PREPARED FOR:               	CS230 Section <section number>
// PROGRAMMER(S):              	< Phillip Harris>
// DEVELOPMENT DATE:           	< 07/09/08>
// COMPILER USED:      			<MS visual studio 2005>
// TARGET PLATFORM:         	< WIN XP >
//================================================================
//                           PROJECT FILES
//    	contributor.h ,contributor.cpp, Lab1.cpp
//================================================================
//                          REVISION HISTORY
//   DATE     PROGRAMMER            DESCRIPTION OF CHANGES MADE
//	<07/08/08	Phil Harris				Original >
//
//================================================================
//              PROCESS THIS FILE ONLY ONCE PER PROJECT
#ifndef	CONTRIBUTOR_H 
#define	CONTRIBUTOR_H
#include <iostream>
#include <string>
using namespace std;
//================================================================
//CONSTANT DEFINITIONS
enum Gender {Male=0, Female, None};                       
class Contributor
{
friend ostream &operator <<(ostream & Out,Contributor &InContrib);
friend istream &operator >>(istream & In, Contributor &InContrib);

public:	
	Contributor();
	Contributor(string InContrib, double InContribution, Gender inSex, int InIDKey);
	Contributor(const Contributor &CCContrib);
	
/////Overloaded Operators
	Contributor &operator=(const Contributor & RtSide);
	bool operator <(const Contributor & RtSide);
	bool operator >(const Contributor & RtSide);
 	bool operator ==(const Contributor & RtSide);
	bool operator!=(const Contributor & RtSide);
	bool insertNode(Contributor i);

private:
	string Name;
	double Contribution;
	Gender Sex;
	int IDKey;	
};

#endif
#include <iostream>
#include <cstdlib>
#include "BSTree.h"
#include "Contributor.h"
using namespace std;

int main()
{
    BSTree myTree;
    Contributor obj1("phillip",32.45,Male,1);
	Contributor obj2("eric",500.98, Male,2);
	Contributor obj3("Raven",245.98,Female,3);
	Contributor obj4("juju",34.56,Female,4);

	myTree.insert(obj1);
	myTree.insert(obj2);
	myTree.insert(obj3);
	myTree.insert(obj4);

	cout<<myTree<<endl;
   
return 0;
}

Well I am sure that my code is right.

It's nice to hear that about the program which you can't compile w/o errors ;)...
Now look at the class BSTree (refactored) interface:

class BSTree
{
public:
        BSTree();
/* Not implemented yet:
    void print_inorder();
    void print_postorder();
    void print_preorder();
*/  
        void insert(Contributor InData);
};

That's all. In other words you can create new BSTree objects then insert Contributor class objects into them. Also you can assign one BSTree object to the other by the default (compiler generated, data member by data member) assignment operator but the only problem is: no data members in this BSTree class at all!

So when you write in the main function:

cout<<myTree<<endl;

you want to get unknown result from an undefined operator <<:

ostream& operator <<(ostream&,const BSTree&);

See Contributor class for example. Look at BSTree declaration again. You promise to implement three member functions to print BSTree. Where are these functions? How binary search tree object can print anything when it's an empty object without data members?

It seems you don't understand your assignment.
Try again then come back...

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