I never used either of those libraries, but I saw that tutorials for FLTK always begin with using namespace fltk;
statement, which imports all FLTK classes, including fltk::Window
to the root namespace.
The library by B. Stroustrup is contained in namespace called Graph_lib
and it also has a class called Window
.
Now, the file Simple_window.h
has using namespace Graph_lib;
statement at the beginning, which imports Graph_lib::Window
to the root namespace. And this is where the ambiguity is coming from.
So I would suggest to omit the using
statement (at least from using namespace fltk
) and to use FLTK classes with full specification (e.g. fltk::Window
instead of just Window
). This should solve the ambiguity.
As a side note, this is nice example, why having using namespace
at file level in a header file is a bad idea.
References:
http://www.fltk.org/doc-2.0/html/index.html
http://www.stroustrup.com/Programming/Graphics/Simple_window.h
EDIT: I tried to compile the library containing Simple_window
myself and, at least under linux, it the ambiguity seems to be between class Graph_lib::Window
from the library and typedef Window
from xlib as well. xlib is C library and you can't really do anything about it, so you will have to get rid of using namespace Graph_lib
in Stroustup's library.
In the file Simple_window.h
:
- delete
using namespace Graph_lib;
- change
Window
to Graph_lib::Window
Button
to Graph_lib::Button
- and
Address
to Graph_lib::Address
Then in the file Simple_window.cpp
:
- change
Address
to Graph_lib::Address
again
- and
reference_to<Simple_window>
to Graph_lib::reference_to<Simple_window>
Then it should compile. If you have different version than the one that's on stroustrup.com, you may need to fully qualify (add Graph_lib::
) more classes.