I maintain a global list of my character data struct in my world manager class, and I’m trying to configure individual AMyCharacter actors to maintain a reference to their data:
The line where I declare characterSheet has an error, “Inappropriate ‘*’ on variable of type ‘FCharacterSheet’, cannot have an exposed pointer to this type”. Does this mean that I’m declaring my struct wrong, or does the struct itself need some kind of special formatting to allow pointers?
That covers the definition, but when I’m trying to make this a variable to be set later (instead of a function argument), I get a different error, to wit “reference must be initialized”. If I’m treating this like a pointer, shouldn’t it auto-initialize to nullptr?
C++ requires references to be initialized. What would an uninitialized reference be? They aren’t pointers, it would be some object in an invalid state, but what would it be referencing, the best a compiler could do for you is make some stack space and call the default constructor on the uninitialized reference, but that is pretty undefined behavior, and better to throw a compiler error than let that get through. This is a language requirement in C++.