Download

Problem with adding element to TArray

Hello mates!

I am trying to add some data to TArray

Here is my .h file



FString StringFromBinaryArray(const TArray<uint8>& BinaryArray);


And here .cpp



FString AActor::StringFromBinaryArray(const TArray<uint8>& BinaryArray)
{
BinaryArray.Add(0);
return FString...
}


And I got following error:



error C2663: 'TArray<uint8,FDefaultAllocator>::Add': 2 overloads have no legal conversion for 'this' pointer


Have anyone met with somthing similiar or have you got some tips or probability solutions?

Thanks!

You are passing the array as a const reference, meaning it can not be modified. If you want to modify the array use a normal reference.

Thanks! Problem solved! :slight_smile: