#include <gtk/gtk.h>
#include <string>
using namespace std;
class WIN
{    
    protected:
    GtkWidget *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;
}
            Asked
            
        
        
            Active
            
        
            Viewed 6,372 times
        
    -3
            
            
         
    
    
        Puppy
        
- 144,682
- 38
- 256
- 465
 
    
    
        Umair Khan
        
- 193
- 1
- 2
- 11
- 
                    Removed C tag as this is clearly not C code. – Puppy Mar 15 '11 at 19:18
- 
                    @Tomalak Geret'kal: Thanks for advices I will take care of these.. – Umair Khan Mar 15 '11 at 20:26
2 Answers
2
            Seems like gtk_widget_show() returns void. That's the void expression you are using in an invalid way.
 
    
    
        Bo Persson
        
- 90,663
- 31
- 146
- 203
1
            
            
        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);
 
    
    
        Erik
        
- 88,732
- 13
- 198
- 189
- 
                    1In C++, `(void)` is unnecessary, it's just `()`. I edited your post accordingly. – Puppy Mar 15 '11 at 19:19
- 
                    3@DeadMG: Please don't. The void was there to illustrate what he was doing, passing void to a function that expected something else. – Erik Mar 15 '11 at 19:21
- 
                    1@DeadMG: It's also rude to edit things that aren't broken, especially when your edit itself is broken. – Lightness Races in Orbit Mar 15 '11 at 19:29