stroustrup的ppp2示例中使用FLTK的窗口图形错误

时间:2018-10-11 08:01:52

标签: c++ window fltk

我收到此错误:

  

C2664'void Graph_lib :: Widget :: attach(Window&)':无法将参数1从'Graph_lib :: Window'转换为'Window&'

这是一些Window.h代码

namespace Graph_lib {

class Shape;    // "forward declare" Shape
class Widget;

class Window : public Fl_Window {

....

和Window.cpp代码,发生错误的地方

namespace Graph_lib {

....

void Window::attach(Widget& w)
{
    begin();            // FTLK: begin attaching new Fl_Wigets to this window

    **// I got error from this function**
    w.attach(*this);    // let the Widget create its Fl_Wigits
    end();              // FTLK: stop attaching new Fl_Wigets to this window
}

....

和具有Widget类的GUI.h代码

namespace Graph_lib {

....

class Widget {

....

virtual void attach(Window&) = 0;

....

我试图进行强制转换并创建一个变量,但这都是相同的。

Window& win = *this;
Graph_lib::Window& win = *this;
w.attach(static_cast<Window&>(*this));
w.attach(dynamic_cast<Window&>(*this));

我该怎么办?

0 个答案:

没有答案