编译Stroustrup时出错';s图形库 我试图用C++的Stroustrup原理和实践来运行一个示例程序,它使用BJARNE的代码,如:代码> SimeLyWeld.H./COD>、图、H、点、H < /代码>。它抛出了一系列错误。通过函数窗口帮助修复了歧义,但仍然有很多错误仍然存在 #include "Simple_window.h" #include "Graph.h" int main() { using namespace Graph_lib; // our graphics facilities are in Graph_lib Point tl(100,100); // to become top left corner of window Simple_window win(tl,600,400,"Canvas"); // make a simple window Polygon poly; // make a shape (a polygon) poly.add(Point(300,200)); // add a point poly.add(Point(350,100)); // add another point poly.add(Point(400,200)); // add a 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 }

编译Stroustrup时出错';s图形库 我试图用C++的Stroustrup原理和实践来运行一个示例程序,它使用BJARNE的代码,如:代码> SimeLyWeld.H./COD>、图、H、点、H < /代码>。它抛出了一系列错误。通过函数窗口帮助修复了歧义,但仍然有很多错误仍然存在 #include "Simple_window.h" #include "Graph.h" int main() { using namespace Graph_lib; // our graphics facilities are in Graph_lib Point tl(100,100); // to become top left corner of window Simple_window win(tl,600,400,"Canvas"); // make a simple window Polygon poly; // make a shape (a polygon) poly.add(Point(300,200)); // add a point poly.add(Point(350,100)); // add another point poly.add(Point(400,200)); // add a 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 },c++,C++,然后抛出以下错误 In file included from GUI.h:11:0, from Simple_window.h:2, from first.cpp:7: Graph.h:159:25: warning: narrowing conversion of ‘fl_color()’ from ‘Fl_Color {aka unsigned int}’ to ‘int’ inside { } [-Wnarrowi

然后抛出以下错误

    In file included from GUI.h:11:0,
                 from Simple_window.h:2,
                 from first.cpp:7:
Graph.h:159:25: warning: narrowing conversion of ‘fl_color()’ from ‘Fl_Color {aka unsigned int}’ to ‘int’ inside { } [-Wnarrowing]
  Color lcolor {fl_color()};

我用g++编译了它,操作系统是LinuxMint。

@Marc不确定——错误看起来好像ctor只接受一个参数。编辑:哦,这是声明——一定是某种解析问题。显示一个最小完整的c文件,包括有问题的头。当我在链接位置查看标题时,它看起来很好,因此可能是缺少大括号或其他一些错误混淆了解析器。@PeterSchneider还有另一个错误
对“Window”的引用不明确
,这是因为标题文件与其中包含的命名空间冲突。所以我认为问题可能出在头文件上你的编译器是什么?站台?给出详细信息manI在cygwin下使用g++编译,并且不得不在Point in.h的ctor中进行注释,该ctor需要2个整数,但除此之外,它工作正常(在解包fltk源代码并将FL头目录作为目录复制到主源代码目录之后)。