c++ - 在 stroustrup 的 ppp2 示例中使用 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
}
....
和 GUI.h 代码,它有 Widget 类
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));
我该怎么办?
解决方案
推荐阅读
- java - Householder 的方法没有返回所需的值
- r - 在 R 中使用公式作为关键字参数(命名参数)和 wilcox.test
- sql - 使用 Derby DB 仅获取作为 SQL 查询结果的返回字符串的长度
- c - 为什么在这个 Linux 补丁中自旋锁应该被 raw_spinlock 替换?
- opencart - opnecart 3.0.3.2 更新错误 Proxy::getGeneralSetting
- reactjs - firestore - 从 firestore 数据收集中填充选择选项
- coldfusion - FindNoCase 不适用于多个单词搜索
- javascript - 如何使用 JavaScript 从二维数组的行中获取所有值的组合?
- java - build.gradle 中的依赖项会自动生成吗?
- angular - SVG 图标在开发模式下显示,但在生产模式下不显示