除了构造函数参数之外,我可以更改 FL_Window 的标题吗?
MainWindow::MainWindow(int w, int h, const string& c)
: Fl_Window(w, h, c.c_str()) // Don't call constructor over here
{
script.load_file(WIN_CONFIG_SCRIPT);
int width = script.get_global_int("width");
int height = script.get_global_int("height");
const char* caption = script.get_global_string("caption").c_str();
/** CALL CONSTRUCTOR NOW **/
//NOTE: I don't know a way to change an FLTK Fl_Window's Caption after
//initialising it.
Toolbar* toolbar = new Toolbar(0, 0, this->w(),30);
toolbar->add_button("Hello");
toolbar->add_button("World!");
end();
}
如何在构造函数内初始化基类?或者,如何在初始化 FLTK Fl_Window 后更改其标题?有没有其他办法摆脱这个混乱局面?
MainWindow::MainWindow(int w, int h, const string& c)
: Fl_Window(w, h, c.c_str()) // Don't call constructor over here
{
script.load_file(WIN_CONFIG_SCRIPT);
int width = script.get_global_int("width");
int height = script.get_global_int("height");
const char* caption = script.get_global_string("caption").c_str();
/** CALL CONSTRUCTOR NOW **/
//NOTE: I don't know a way to change an FLTK Fl_Window's Caption after
//initialising it.
Toolbar* toolbar = new Toolbar(0, 0, this->w(),30);
toolbar->add_button("Hello");
toolbar->add_button("World!");
end();
}
How do I initialize the base class inside the constructor? Alternatively, how do I change an FLTK Fl_Window's caption after initialising it? Is there any other way out of this mess?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可能不会。
实例的基础部分必须在实例的派生部分或其任何成员之前初始化。
文档说你可以打电话:
这有什么问题吗?
不可以。
另外,您应该升级到 FLTK 2。
You may not.
The base part of the instance must be initialised before the derived part of the instance or any of its members.
The documentation says you can call:
What's wrong with that?
No.
Also, you should upgrade to FLTK 2.