Howdy folks,
So I’m having a bit of trouble finding a way to do this. I have a function that accepts a TArray as a param. However, there are some times when I call this function but do not wish to pass any data into the TArray, thus I’d like to pass NULL or some equivalent. When I try to pass Null as the parameter, I get
“error C2664: ‘void myfunction(TArray)’ : cannot convert argument
No consturctor could take the source type, or consturctor overload resolution was ambiguous”
A bit of background, this is code I’m converting from another language for work so I’m trying to keep it as close to source as possible. Source of the code was written in ActionScript 3.
So my question is, is there a way to pass a Null to the TArray as the target function does a check to see if the array is null or not?
A solution I came up with was to make another TArray that never gets used and thus should be ‘empty’ and just use that in place of the Null and to check it’s .Num() method instead of the ‘null’ check already present in the code. But I’m not sure if that is optimal or not.
If someone needs a code sample, I can whip up a dummy version of what I’m doing to help.
Thanks in advance.
EDIT: 2/3/2015
I’d like to thank ScottSpadea for his useful info of Overloads. I had forgotten all about them. While that would work if this was the only issue, I found there was more to this code.
The function I am referring too above is being funneled to a sort of translator struct in another file. There are several other files with similar functions to the one above and just different names / different operations based on what the file is for. The overall project is dealing with different printer devices that we support. Most will have a lot of code that is similar except for a few lines and such depending on the manufacturer specifications and such. I know that we could just use encapsulation and make some base/derived classes and fix the need for a translator struct but, as stated before, the higher ups want to keep the code as close to source as possible.
So far the empty TArray I came up with seems to be working but it just feels like there should be some other way to do this. Sorry if I ramble.