Adding uint16 pointer to an array of uint16 pointer

I have an array of uint16* pointers.


TArray<int16*> HoldingValues;


I have a function that takes a reference and adds a pointer in the array to that reference. But neither of these 2 methods work.


const bool AddPointerValue(uint16 &StackValueHolder)
{
	StackValueHolder = TotalStacks;
	uint16* TempIntegerPointer = &StackValueHolder;
	HoldingValues.Add(&StackValueHolder); // Doesn't work
	HoldingValues.Add(TempIntegerPointer);// Doesn't work
	return true;
}

Anyway how to do it?

Basically what I want to do is, I have a few integers spread through out many classes which take a master value. When the master value is changed, i want to have pointers to all the integers which derive from it. So I want to store the pointer to those values in an array and when the master value changes, all values should change.

I’m not in a mindset for pointer manipulation, but for your problem, perhaps you would consider creating a class that encapsulates the values you want to keep synchronized. So rather than having the many classes (lets call them listeners) that each have a pointer array, give each listener a pointer to one object that contains all values. That one object could have one TArray then, not of pointers but the actual data. Would that work?

I’m having the exact same problem. In the meantime I’m using Append since that seems to work properly but I don’t think it does exactly the same.