Workaround overriding a static variable?

Hi!

There is no workaround. Static variables are fully equal to global variables, just hidden inside class namespace. So your basic information is the same for all classes derived from BaseItem.

Simplest way, don’t use static variables. Just duplicate necessary information.
Also, you can create struct BasicItemInfo, that contains all basic information (Name, Description, Weight, Cost). Create a global array with information for each inventory item type. And BaseItem class should store only index (non static variable) to a some item of this array.

Something like this:



struct BaseItemInfo
{
	char name[64];
	char description[256];
	float weigh;
	int cost;
};

BaseItemInfo g_BaseItemInfo] = 
{
	{ "", "",  0,  0 },
	{ "Item 1", "Description 1", 10, 10 },
	{ "Item 2", "Description 2", 20, 20 }
};

class BaseItem
{
protected:
	
	int index;
	
public:

	BaseItem() : index(0) {}
};

class Item1 : public BaseItem
{
protected:

	int someNewInfo;
	
public:
	
	Item1() : someNewInfo(0) { index = 1; }
};

class Item2 : public BaseItem
{
protected:

	float anotherInfo;
	
public:
	
	Item2() : anotherInfo(0) { index = 2; }
};


PS: Sorry for my English :rolleyes:
PPS: Also you can use UDataTable class for storing common information.