hi,
i'd like to use a singleton for one of my classes. The class has an attribute named oid and i will need one instance for every value of oid - i just need to make sure there is no second one.
so i tried:
class cAnlagenArt {
public:
static cAnlagenArt
* self
( QString oid
);
private:
static QMap<QString, cAnlagenArt* > _self;
}
class cAnlagenArt {
public:
static cAnlagenArt* self( QString oid );
private:
static QMap<QString, cAnlagenArt* > _self;
}
To copy to clipboard, switch view to plain text mode
and tried the following:
cAnlagenArt
* cAnlagenArt
::self(QString oid
) { if ( ! _self.contains(oid) )
_self[oid] = new cAnlagenArt( oid );
return _self[oid];
}
cAnlagenArt* cAnlagenArt::self(QString oid) {
if ( ! _self.contains(oid) )
_self[oid] = new cAnlagenArt( oid );
return _self[oid];
}
To copy to clipboard, switch view to plain text mode
which gets me lots of
undefined reference to `cAnlagenArt::_self'
how else can i do this?
Bookmarks