Re: Re: C++-classes.



All is not lost. You can do exactly what you >want. This is how:
class GtkClass
{
   GtkWidget *button; // private by default

   static void Test(); // no this pointer for
                       // static methods

public:
   GtkClass();
};

GtkClass::GtkClass()
{
   button = gtk_button_new();

   gtk_signal_connect(GTK_OBJECT(button),
"clicked", GTK_SIGNAL_FUNC(&GtkClass::Test), 0);       // C++ doesn't use NULL. It's a C macro.
}

Ah, then I came up to another problem. If you then want to modify the "calling" class variable, for example 
the GtkWidget *button.

If you do a:

void GtkClass::Test()
{
  gtk_widget_hide(button);
  // or a GtkClass::button?
  // or even call another method in GtkClass?
}

it doesn't seem to work. How can i fix this?

// David




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]