Re: [gtkmm] static Glib::RefPtr<>'s
- From: Jay Camp <jayc CLEMSON EDU>
- To: gtkmm-list gnome org
- Subject: Re: [gtkmm] static Glib::RefPtr<>'s
- Date: Tue, 01 Jun 2004 21:12:04 -0400
Oops! Thanks. I'm still getting the linking error though after fixing
that. Forgot to insert that last time:
/usr/include/glibmm-2.4/glibmm/refptr.h:155: undefined reference to
`Glade::get() in MainWindow.o(.text+0x5c): In function
`MainWindow::connect_menu()':
I have my Glade.h included in the file I want to use it, and am
accessing it like this:
Glade::get()->get_widget("menu_file_quit", menuItem);
(menuItem is already declared and defined)
Thanks!
On Tue, 2004-06-01 at 20:46, Bowie Owens wrote:
> Jay Camp wrote:
>
> >I'm trying to create a singleton class to use for a variable that's a
> >RefPtr<>. It compiles, but fails to link when used. Are there any
> >problems with using a static RefPtr<> in this way? The code isn't very
> >long, so I have pasted it below. Any tips would be much appreciated:
> >
> >
> Is this all your code? Your program won't link because you have declared
> but not defined Glade::instance. You need a line in your .cc file:
>
> Glib::RefPtr<Gnome::Glade::Xml> Glade::instance;
>
>
> >FILE: Glade.h
> >
> >#ifndef GLADE_H
> >#define GLADE_H
> >
> >#include <glibmm.h>
> >#include <libglademm.h>
> >
> >class Glade {
> >
> > public:
> > static Glib::RefPtr<Gnome::Glade::Xml> get();
> >
> > protected:
> > Glade();
> > Glade(const Glib::RefPtr<Gnome::Glade::Xml>&);
> > Glade& operator= (const
> > Glib::RefPtr<Gnome::Glade::Xml>&);
> >
> > private:
> > static Glib::RefPtr<Gnome::Glade::Xml> instance;
> >};
> >
> >#endif
> >
> >FILE: Glade.cc
> >
> >#include "Glade.h"
> >
> >Glib::RefPtr<Gnome::Glade::Xml> Glade::get() {
> >
> > if (instance)
> > instance = Gnome::Glade::Xml::create("glade/k5.glade");
> >
> > return instance;
> >}
> >
> >Glade::Glade() { }
> >
> >
> >
> >
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]