![]() |
| ||
| binary tree class 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> 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' |
| ||
| Re: binary tree class nevermind... got it. |
| ||
| Re: binary tree class alright my insert function is: bool binaryTree::insert(dataNode*& tree, int &flightNumber) {and im guessing i need to put the information thats typed in... here in the insert function too.. but im not sure how to do that... because i have always done just *current with the linked lists and im confused about doing it with the left and right... here is the info fields...: typedef struct dataNode {im sure i need to do a comparision like... if (flightNumber < root -> flightNumber) however i dont think that will cover everything and i dont know if it would balance the tree.... plus im not exactly sure where to put that into the insertion function... and i just compare the flightnumbers but all the data in the struct needs to be... attatched to that one flight number.... i have to have it search for a flight then cout all the information that is linked with that flightnumber... or city or whatever the search field is... am i on the right track? and where do i go from here? |
| ||
| Re: binary tree class >but im not sure how to do that It would be easier to build the data part of a node in your client code and pass it to the binary tree class. That would involve something like this: struct data {Then the input function could be easily modified:bool binaryTree::insert(dataNode*& tree, data item) {>i dont know if it would balance the treeNo, it won't. Balancing is much more complicated than that. I have several binary search tree tutorials on my website if you want to take a look at them. |
| ||
| Re: binary tree class Thanks narue.. I already did some other things by the time i saw this post. But I have more problems with it. And my code looks alot different tahn before. I changed the majority of everything to get it to work. and it does compile!!!! #include <iostream> tried to minimize the main function. Anyways, it goes to the menu and lets you select an option... if type in an invalid choice that works.. and if you pick the option to quit that works, all the others seen to just keep looping around. am i calling my functions wrong or are my functions just wrong period? i think my insert is lacking? and as a quick side topic... we never had to write destructors before so i know itll be more than delete root... what else is needed there? |
| ||
| Re: binary tree class For my benefit, could you fix this part: typedef struct dataNode {The name of the typedef is between the } and the ; - that empty part. I've tried to look at some things a number of times, but these little fixits here and there begin to discourage me.Because, you see, for me it does not compile. Quote:
|
| ||
| Re: binary tree class i dont understand? just delete the word typedef? |
| ||
| Re: binary tree class sorry dave, i still dont know what you were asking me to remove. so for everyone else out there... my program is seg faulting. and a debugger isnt helping so i am wondering you anyone can pick up on the problem that i am overlooking... it allows you to input information but if you want to search - display information off menu option 2 then any of the search options - the program seg faults... i changed my while loop from (root != Null) to (tree != Null) and that didnt fix it... any other ideas? thank you. #include <iostream> |
| All times are GMT -4. The time now is 10:51 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC