开发者

no matching function for call to ‘Gtk::Main::run(window (&)())

I guess I'm not understanding something about C++:

I have this code:

#include "window.h"

int main(int argc, char* argv[]) {
    Gtk::Main kit(argc, argv);
    window win();
    Gtk::Main::run(win);

    return EXIT_SUCCESS;
}

'window' is a class that inherits from Gtk::Window with an empty constructor. When I try to compile this code, I get this error:

开发者_如何学JAVAno matching function for call to ‘Gtk::Main::run(window (&)())

However, if I change the line:

window win();

to

window win;

then the code compiles. How do the presence/absence of the parentheses change things? I've run into this before and never understood what was going on. What's happening?


Because window win(); is the declaration of a function taking no parameters and returning a window. (Hence the error saying no matching call for window (&)(), which is that type.)

This is known as the "Most Vexing Parse."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜