我正在尝试使用C ++运行Stroustrup的原理和实践中的示例程序,该程序使用Bjarne的library,例如Simple_window.h
,Graph.h
,Point.h
。它引发了一系列错误。 This SO question帮助修复了函数Window
的歧义,但仍然存在很多错误。
#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
}
然后抛出以下错误
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 ++编译它,操作系统是Linux Mint。