Ok. Perhaps there is a better way to design this though. This is what I have and I don't know of a better way without using globals.
(next two blocks are in namespace Item)
Code:
class Item {
private:
const unsigned short sprite;
public:
static const std::vector<std::string> *strings;
virtual void aquire()=0;
Item(const unsigned short&);
virtual ~Item();
};
Item::Item(const unsigned short& a): sprite{a} {}
Item::~Item() {}
const std::vector<std::string> *Item::strings{}; //the static construct
This is how Item will be used, as the strings std::vector.
Code:
class Smallkey: public Item {
public:
void aquire();
Smallkey();
};
Smallkey::Smallkey(): Item{0} {}
void Smallkey::aquire() {
std::cout<<(*strings)[0]<<std::endl;
}
main, where assignment occurs.
Code:
//this is main
const std::vector<std::string> strings{"Foo","Foo","Foo","Foo","Foo","Foo","Foo"};
Item::Item::strings=&strings; //the relevant construct
edit: the reason I don't have the std::vector with the data in the actual class is because more classes will use this vector, and it will be loaded dynamically at run-time.