All pastes #923198 Raw Edit

Mine

public cpp v1 · immutable
#923198 ·published 2008-02-29 10:28 UTC
rendered paste body
tmp/map.o: In function `Map::unloadMap(Map*)':map.cpp:(.text+0x6e): undefined reference to `Map::maps'map.cpp:(.text+0xa9): undefined reference to `Map::maps'tmp/map.o: In function `Map::getMap(QString)':map.cpp:(.text+0x10b): undefined reference to `Map::maps'map.cpp:(.text+0x136): undefined reference to `Map::maps'map.cpp:(.text+0x146): undefined reference to `Map::maps'tmp/map.o:map.cpp:(.text+0x167): more undefined references to `Map::maps' followcollect2: ld returned 1 exit status//-----------------------------------------------------------------------//-----------------------------------------------------------------------// map.h#ifndef MAP_H#define MAP_H#include <QMap>#include <QString>class Map{public:    static Map *getMap(QString name);    static void unloadMap(QString name);    static void unloadMap(Map *map);    void used() { gamesUsing++; };    void notUsed() { gamesUsing--; if(!gamesUsing) unloadMap(this); };    protected:    static QMap<QString, Map *> maps;    Map(QString name);    const QString name;    unsigned short gamesUsing;};#endif//-----------------------------------------------------------------------//-----------------------------------------------------------------------// map.cpp#include "map.h"Map::Map(QString name)  : name(name),    gamesUsing(0){}Map *Map::getMap(QString name){    if(maps.contains(name))        return maps[name];        // TODO: What if the map file doesn't exist? Need to return 0 if that happens    maps[name] = new Map(name);}void Map::unloadMap(QString name){    if(!maps.contains(name))        return;    if(maps[name]->gamesUsing)        return; // Don't unload if a game is using it        delete maps[name];    maps.remove(name);}void Map::unloadMap(Map *map){    if(map->gamesUsing)        return; // Don't unload if a game is using it        QString name = maps.key(map);    delete map;    maps.remove(name);}