Source code from Nyhoff book won't compile on Visual C++ 2008
I have been reading code-guru posts for quite some time now over the last year, and am glad to finally be a member of the forum on a formal basis.
I am brushing up on some of my data structure knowledge, and have recently completed a class in data structures taught out of a book called "ADTs, Data Structures and Problem Solving with C++" by Larry Nyhoff. The book is replete with c++ code for creating linked lists, binary search trees, and other such data structures. The book is the second edition, and is copyrighted (c) 2005.
The problem I have been having for quite some time now is that an abnormal amount of the code in this book will not compile at all using the Visual Studio 2008 IDE. After hours and hours of searching, I often times find that the author forgot to list some #include statement, or some other feature.
I am not particularly cynical of Nyhoff. He is a professor of computer science at a university, and surely he's not so stupid as to totally forget things like this. Nevertheless, only about 1/10th of the code snippets in this book will actually compile. I am aware of a variety of changes that took place to the ANSI C++ standards in 2003, but the Nyhoff book is (c) 2005, and the code seems to be fairly up to date.
Although I am not a particularly strong C++ programmer (most of my bioinformatics and drug discovery algorithms are written in python -- certainly my strongest language), but it's not like I can't write a while-loop in the C++ language. As far as my experience level in C++, I can write a doubly-linked circular list -- so I don't think that all of this is simply due to inability to type correctly or inability to read and understand straightforward code.
I'm curious to know if anyone is aware of what the problem might be with Nyhoff's code in his fairly voluminous book of data structures. Why is it that the lion's share of his code will not even begin to compile, producing as many as 20 - 30 compile-time errors and other fatalities?
Finally, I realize that this problem may be difficult to solve without at least seeing some of the problematic code -- I'd be happy to email some of Nyhoff's non-compiling code to anyone who wants to look at it, I just didn't want to post 300 some-odd lines of code in the forum. I could also post some of the error messages at anyones requests (although they are a bit lengthy as well).
Re: Source code from Nyhoff book won't compile on Visual C++ 2008
Originally Posted by BrentC
Why is it that the lion's share of his code will not even begin to compile, producing as many as 20 - 30 compile-time errors and other fatalities?
Maybe because the code is wrong? I don't know the author, but you can be a genius at data structures and at the same time be a mediocre C++ programmer, or at least one that isn't careful about C++ language rules.
Finally, I realize that this problem may be difficult to solve without at least seeing some of the problematic code
No, the problem is impossible to solve without seeing the code.
I'd be happy to email some of Nyhoff's non-compiling code to anyone who wants to look at it, I just didn't want to post 300 some-odd lines of code in the forum.
It doesn't take a 300 line program to produce a compiler error. Any compiler error can be duplicated with a minimal example.
Take the 300 or whatever number of lines, cut it down to a complete program that produces the error. It doesn't matter what the minimal program does or does not do, the goal is to produce an example of the compiler error that can be duplicated easily. The code must be complete enough so that we do not have to add or remove any lines ourselves. Then post that code here.
Last edited by Paul McKenzie; May 9th, 2010 at 09:03 AM.