Re: [gtkmm] adding a widget to a container



On Tue, May 04, 2004 at 10:37:50AM +0200, cedric wrote:
> >>so to do this, i ve 2 ptr declared in my Plugin.hh file
> >>  static Gtk::HBox *toolBarModContainer_ptr;
> >>  static Gtk::Toolbar *toolBarModDisplayed_ptr;

Do you mean within a class declaration? If so, you'll also need to
define them in a .cc file, without using the static keyword, eg:
// in fred.h
class fred
{
static Gtk::HBox* hbox;
};

// in fred.cc
Gtk::HBox* fred::hbox = 0; // and you can initialise it too

In this case there is only one variable, even if fred.h is included
multiple times. (Which is different to how it would be if the variable
were declared outside of a class definition, but there wasn't enough
context from your earlier mails for me to work out whether it was in a
class or not.)

> it s a seg fault, but there is a link error instead if declare 
> toolbarmod as static.

Obviously with the above, you will still need something to set that
pointer to a sensible value before you use it.

~Ainsley



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