开发者

Error: Invalid use of void expression [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.
#include <gtk/gtk.h>
#include <string>

using namespace std;

class WIN
{    
    protected:
    Gt开发者_运维百科kWidget *window;

    public:

    GtkWidget* get_window(){ return window; }
    void set_window(GtkWidget* w){ window = w; }
    void set_title(string s) 
    {
        gtk_window_set_title (GTK_WINDOW(window), s.c_str());
    }

};

int main (int argc, char *argv[])
{
    /* Initialize GTK+ and all of its supporting libraries. */
    gtk_init (&argc, &argv);
    WIN obj1;
    obj1.set_window(gtk_window_new (GTK_WINDOW_TOPLEVEL));
    obj1.set_title("Hello World");
    GtkWidget *w = obj1.get_window();
    obj1.set_window(gtk_widget_show(w));

    /* Hand control over to the main loop. */
    gtk_main();
    return 0;
}


Seems like gtk_widget_show() returns void. That's the void expression you are using in an invalid way.

http://library.gnome.org/devel/gtk/2.99/GtkWidget.html


gtk_widget_show() returns void.

You're calling obj1.set_window(void)

Change:

obj1.set_window(gtk_widget_show(w));

To

gtk_widget_show(w);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜