Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to get the filepath which is selected? Pin
Code-o-mat25-Apr-10 1:23
Code-o-mat25-Apr-10 1:23 
QuestionOpenGL help! Pin
epinez24-Apr-10 16:48
epinez24-Apr-10 16:48 
AnswerRe: OpenGL help! Pin
Tim Craig24-Apr-10 16:58
Tim Craig24-Apr-10 16:58 
GeneralRe: OpenGL help! Pin
epinez24-Apr-10 17:04
epinez24-Apr-10 17:04 
GeneralRe: OpenGL help! Pin
Tim Craig24-Apr-10 19:37
Tim Craig24-Apr-10 19:37 
GeneralRe: OpenGL help! Pin
Cedric Moonen25-Apr-10 1:15
Cedric Moonen25-Apr-10 1:15 
AnswerRe: OpenGL help! Pin
Saurabh.Garg24-Apr-10 17:50
Saurabh.Garg24-Apr-10 17:50 
QuestionOverloading operator== for custom class and NULL? Pin
yashachan24-Apr-10 12:59
yashachan24-Apr-10 12:59 
My professor decided it'd be a wonderful idea to have us code a binary search tree. I'm somewhere in my fourth or fifth attempt, and I'm about to break something I'm so frustrated.

So, where I'm at: I've currently got two classes, BST for the tree, and BSTN for the tree's nodes. I'm attempting to write an insert function, and I'm using the pseudo-code from Introduction to Algorithms (3rd ed) to guide me (is it okay to post that pseudo-code on a forum?). I just seem to keep not being able to get my code to work (and please forgive me if I'm a bit slow... I haven't done much with C++ in over a year).

BST.h

BSTN.h


I've opted for pastebin, so I could highlight the specific lines that I'm having trouble with (in BST.h). So, the three I have highlighted are where I've departed from the pseudo-code, and two of them are why I think I need to overload operator==. On line 39, the pseudo-code says to check that currNode is not NULL, but it never evaluates to false if I use the condition currNode != NULL. Line 48 I don't think should be commented out, but if I assign the parent there, if the node happens to be the root, it won't have the NULL parent that it should, so I don't get why they think it ought to be done there. And line 50 should have the condition currNode == NULL, but that will never evaluate to true.

Do I need to overload operator==? If so, how do I do it? I've tried several times and nothing has worked. Or are my slight modifications to the pseudo-code's method going to work fine?

And once this is sorted out, I probably have more questions. Big Grin | :-D

Oh, and I'm using Visual C++ Express 2008.
AnswerRe: Overloading operator== for custom class and NULL? Pin
Saurabh.Garg24-Apr-10 15:48
Saurabh.Garg24-Apr-10 15:48 
GeneralRe: Overloading operator== for custom class and NULL? Pin
yashachan25-Apr-10 1:56
yashachan25-Apr-10 1:56 
GeneralRe: Overloading operator== for custom class and NULL? Pin
Saurabh.Garg25-Apr-10 2:03
Saurabh.Garg25-Apr-10 2:03 
GeneralRe: Overloading operator== for custom class and NULL? Pin
Saurabh.Garg25-Apr-10 2:57
Saurabh.Garg25-Apr-10 2:57 
GeneralRe: Overloading operator== for custom class and NULL? Pin
yashachan25-Apr-10 5:16
yashachan25-Apr-10 5:16 
GeneralRe: Overloading operator== for custom class and NULL? Pin
Saurabh.Garg25-Apr-10 5:34
Saurabh.Garg25-Apr-10 5:34 
QuestionAdding items to the title bar Pin
hans.sch24-Apr-10 8:18
hans.sch24-Apr-10 8:18 
AnswerRe: Adding items to the title bar Pin
KingsGambit24-Apr-10 8:36
KingsGambit24-Apr-10 8:36 
GeneralRe: Adding items to the title bar [modified] Pin
hans.sch24-Apr-10 9:03
hans.sch24-Apr-10 9:03 
GeneralRe: Adding items to the title bar Pin
Emilio Garavaglia24-Apr-10 10:40
Emilio Garavaglia24-Apr-10 10:40 
GeneralRe: Adding items to the title bar Pin
hans.sch24-Apr-10 15:10
hans.sch24-Apr-10 15:10 
AnswerRe: Adding items to the title bar (solved) [modified] Pin
hans.sch17-Jun-10 21:30
hans.sch17-Jun-10 21:30 
QuestionHow to avoid Buffer Overrun?! Pin
Fareed Rizkalla24-Apr-10 7:38
Fareed Rizkalla24-Apr-10 7:38 
AnswerRe: How to avoid Buffer Overrun?! Pin
Rajesh R Subramanian24-Apr-10 7:41
professionalRajesh R Subramanian24-Apr-10 7:41 
AnswerRe: How to avoid Buffer Overrun?! Pin
Moak24-Apr-10 9:06
Moak24-Apr-10 9:06 
AnswerRe: How to avoid Buffer Overrun?! Pin
Saurabh.Garg24-Apr-10 17:55
Saurabh.Garg24-Apr-10 17:55 
AnswerRe: How to avoid Buffer Overrun?! Pin
RedZombie12527-Apr-10 16:45
RedZombie12527-Apr-10 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.