Re: [gtkmm] static Glib::RefPtr<>'s
- From: Bowie Owens <bowie owens csiro au>
- To: Jay Camp <jayc CLEMSON EDU>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] static Glib::RefPtr<>'s
- Date: Wed, 02 Jun 2004 10:46:36 +1000
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() { }
--
Bowie Owens
CSIRO Mathematical & Information Sciences
phone : +61 3 9545 8055
fax : +61 3 9545 8080
mobile : 0425 729 875
email : Bowie Owens csiro au
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]