PPP Chapter 12 Headers

In Chapter 12 of Stroustrup's "Programming Princpiples and Practice using C++" book, it requires you to download these headers: http://www.stroustrup.com/Programming/Graphics/index.html

This chapter depends on the FLTK library, (Which I have successfully installed version 1.3.2 of, I know as I tested various code pieces about FLTK from various websites)
and it relies on this mysterious "fltk.h" file, which I haven't seen anywhere.
Multiple files from that link "#include "fltk.h" ", so it must be important.

I have version 1.3.2 of FLTK and I am using the Visual Studio 2010 IDE.

There are also strange code segments in Graph.h, where things have been commented out, I am unaware if this is intentional.

1
2
3
4
5
6
7
8
9
10
/*

struct Marks : Shape {
	Marks(char m) : mark(string(1,m)) { }
	void add(Point p) { Shape::add(p); }
	void draw_lines() const;
private:
	string mark;
};
*/


One thing I have tried to fix the errors I had, was to un-comment everything and to replace any thing that says""fltk.h"", with "<FL/FL.H>". I had no success.

This is the code that should of worked and produced a Canvas with a triangle in it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
#include "Simple_window.h" //get access to our window library
#include "Graph.h"         //get access to our graphics library facilities

int main()
{
using namespace Graph_lib; //our graphics facilities are in Graph_lib

Point t1(100,100); //to become top left corner of window

Simple_window win(t1,600,400"Canvas"); //make a simple window

Polygon poly;

poly.add(Point(300,200)); //add point
poly.add(Point(350,100)); //another point
Poly.add(Point(400,200)); //third point

poly.set_color(Color::red);  //adjust properties of poly

win.attach(poly);      //connect poly to the window

win.wait_for_button(); //give control to the display engine
}


Help would be great, maybe someone could also just send me the "fltk.h" file too.
Last edited on
You can find the fltk.h file here:
http://www.stroustrup.com/Programming/PPP2code/fltk.h

Note that it is simply an include of other headers in the /FL/ directory, so make sure you have the /FL/ directory installed and that your compiler knows where to look for it.

Thank you so much!
Last edited on
*sigh*

Now I'm having compiler errors, all of which are in his header files...

EDIT: I believe the problem was due to me using a too recent version of FLTK, I will downgrade to 1.1.9.
Last edited on
Topic archived. No new replies allowed.