#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,340 times
-3
![](../../users/profiles/298661.webp)
Puppy
- 138,897
- 33
- 232
- 446
![](../../users/profiles/442988.webp)
Umair Khan
- 175
- 1
- 2
- 9
-
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.
![](../../users/profiles/597607.webp)
Bo Persson
- 86,087
- 31
- 138
- 198
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);
![](../../users/profiles/616700.webp)
Erik
- 80,488
- 12
- 185
- 183
-
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