我正在尝试使用FLTK制作一个窗口(快速拍摄套件)。编译时我收到此错误。请有人帮忙!
我的代码在fltk1.cpp
#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
//Drawing functions
#include <FL/fl_draw.H>
// Subclass of Fl_box
class dotbox : public Fl_Box {
int x = 180;
public:
using Fl_Box::Fl_Box; //Inherits the constructor from base (C++11)
void draw() override{ //Override draw from box ('override' er C++11)
fl_color(FL_RED);
fl_pie(160,80,30,30,0,360); //draw
fl_color(FL_GREEN); //...repeats
fl_pie(170,90,40,40,0,360);
fl_color(FL_BLUE);
fl_pie(x++,100,30,30,0,360);
}
};
错误:编译时得到的内容:
Building for 1.3.3
g++ -std=c++11 fltk1.cpp -o fltk1 -L/usr/local/lib -lfltk -lXfixes -lXext -lpthread -ldl -lm -lX11
fltk1.cpp:15:15: error: ‘Fl_Box::Fl_Box’ names constructor
fltk1.cpp: In function ‘int main(int, char**)’:
fltk1.cpp:50:37: error: no matching function for call to ‘dotbox::dotbox(<brace-enclosed initializer list>)’
fltk1.cpp:50:37: note: candidates are:
fltk1.cpp:11:7: note: dotbox::dotbox() <deleted>
fltk1.cpp:11:7: note: candidate expects 0 arguments, 4 provided
fltk1.cpp:11:7: note: dotbox::dotbox(const dotbox&) <deleted>
fltk1.cpp:11:7: note: candidate expects 1 argument, 4 provided
fltk1.cpp:51:41: error: no matching function for call to ‘dotbox::dotbox(<brace-enclosed initializer list>)’
fltk1.cpp:51:41: note: candidates are:
fltk1.cpp:11:7: note: dotbox::dotbox() <deleted>
fltk1.cpp:11:7: note: candidate expects 0 arguments, 4 provided
fltk1.cpp:11:7: note: dotbox::dotbox(const dotbox&) <deleted>
fltk1.cpp:11:7: note: candidate expects 1 argument, 4 provided
make: *** [fltk] Error 1
有什么想法吗?
我通过取消注释解决了这个问题,
//使用FL_Box :: Fl_Box;
并添加这行代码。
dotbox(int X, int Y, int W, int H) : Fl_Box(X, Y, W, H, 0) {}
答案 0 :(得分:0)
我通过取消注释解决了这个问题,
//using FL_Box::Fl_Box;
并添加此行代码。
dotbox(int X, int Y, int W, int H) : Fl_Box(X, Y, W, H, 0) {}