"Graph.h" from Bjarne Stroustrup not working

I am learning Chapter 12 of "Programming - Principle and Practice (Second edition)" and I met some problems while doing its Drill. After I include "Graph.h", add "Graph.cpp"(Path is right) to my project and want to complie, Visual C++ complier reports a lot of errors, all from the two files above. FLTK works well. Anyone who has the book and succeeded in getting the program to complie? Pls show me how to.

The code is very simple (using FLTK):
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "../../Graph.h"
#include "../../Simple_window.h"
#include "../../std_lib_facilities.h"

using namespace Graph_lib;

int main()
{
	Point tl{ 100, 100 };

	Simple_window win{ tl, 600, 400, "Canvas" };
	win.wait_for_button();
}
Last edited on
That's because they're almost certainly wildly outdated (and often erroneous) from publishing date.

Try these:

https://github.com/Yawzheek/Stroustrup-Graphics

I can't take all the credit (I found a lot of it online), they're not the best, and no assurance that they'll work, but you should download those files, and verify you followed the directions for installing FLTK VERY, VERY, VERY carefully. Mind you, I "corrected" those months ago when I had no real business even being in the headers.

EDIT: And for the love of God, install it as it instructs in Appendix A, then run the test!
Last edited on
> That's because they're almost certainly wildly outdated
screw backward compatibility

> complier reports a lot of errors
¿have you tried turning it off and on again?
Thing is, I don't even know if it was backwards compatibility or just erroneous headers though. I must have spent 12 hours racking my brain trying to sort it out (that's not an exaggeration) and using the web to locate answers, and a significant portion of it was needing to comment out specific lines. I kept those files on-hand specifically because I figured another beginner would have the same issues. Glad I did now.

By no means am I perfect, and I don't expect it from Stroustrup either, but I sincerely hope it's a backwards compatibility issue, because it was one of the most frustrating parts I've had (so far) in programming, and by no means at the time (and for the most part to this day) had no real idea what I was doing. That's an awful burden to lay on the beginner.
Thank you very much Yawzheek.

After using the head and .cpp files you provide, my program can, for the first time, complie and run. Hope that everyone that have the same problem try this solution.
Glad to hear it man. I'll leave it up, or if someone wants to publish it somewhere else in case I accidentally delete them that would be great too.

I considered skipping those chapters because of the frustration getting it to work, but I'm glad I didn't. They're REALLY important chapters you'd do well to take your time on.

Good luck man!
Topic archived. No new replies allowed.