PPP2 stands for "Programming: Principles and Practices using C ++ 2nd edition"
There is an effort going on from volunteers who want PPP2 book programs running without problems and on other non-Windows systems, such as Linux.
You can see it here:
https://groups.google.com/forum/#!topic/ppp-public/BtlzdWGuQpQ
Now everything is working normally using gui2.tar.gz (on link above), however on page 432 the book presents a code similar to this:
------------begin main.cpp-----------------------------
#include "Simple_window.h"
#include "Graph.h"
int main()
{
using namespace Graph_lib;
Point tl {100,100};
Simple_window win {tl,600,400,"Canvas"};
Text t{Point{150,150}, "Hello, graphical world!"};
win.attach(t);
t.set_font(Font::times_bold);
t.set_font_size(20);
win.wait_for_button();
return 0;
}
------------end main.cpp-------------------------------
And the compiler shows the following error message:
-----------------begin Error message-------------------
main.cpp:14:13: error: reference to 'Font' is ambiguous
t.set_font(Font::times_bold);
^
/usr/local/include/X11/X.h:100:13: note: candidate found by name lookup is 'Font'
typedef XID Font;
^
./Graph.h:56:7: note: candidate found by name lookup is 'Graph_lib::Font'
class Font {
^
1 error generated.
*** Error code 1
-----------------end Error message---------------------
That is, PPP2 Graph_lib's "Font" is conflicting with Xorg's "Font".
I know how to fix:
------------begin main2.cpp-----------------------------
#include "Simple_window.h"
#include "Graph.h"
int main()
{
using namespace Graph_lib;
Point tl {100,100};
Simple_window win {tl,600,400,"Canvas"};
Text t{Point{150,150}, "Hello, graphical world!"};
win.attach(t);
t.set_font(Graph_lib::Font::times_bold);
t.set_font_size(20);
win.wait_for_button();
return 0;
}
------------end main2.cpp-------------------------------
I have just changed
from line:
t.set_font(Font::times_bold);
to
t.set_font(Graph_lib::Font::times_bold);
Making it clear that the Font is from the Graph_lib namespace.
But I would like to know if there is any way to make the program work without having to change the main.cpp program so that the original code was
preserved and consequently the code from book did not have to have a "special case". Any suggestion is welcome.
The Graph_lib + main2.cpp + my Makefile can be downloaded here:
http://35.167.12.56/program.tar.gz
Assuming FLTK lib installed in "/usr/local/" and C++ compiler command being "CC"