I'm attempting to port some old code over from C# to C++, and I need to know if there's an efficient/clean method to translate a C# constructor that takes an argument of a params object[] over to C++.
In my example, I have the following simple constructor:
public ParameterDescriptor(bool required, ParameterType parameterType, params object[] values)
{
this.optional = optional;
this.parameterType = parameterType;
this.defaultValues.AddRange(values);
}
Where the values being inputted into the third argument can range from being absolutely blank to any number of command strings, i.e. "ON", "OFF", "RESET". These command strings then get added to a List containing each object value, through the following:
List<object> defaultValues = new List<object>();
public List<object> DefaultValues
{
get { return this.defaultValues; }
set { this.defaultValues = value; }
}
Is there any method in C++ that would achieve the same result here? That is to say, accept any number of string arguments from None to a large amount in the constructor and store them in a list/vector?
I feel as though multiple constructors for varying lengths of command strings would work, but that doesn't solve the possibility of an unknown X amount of strings being inputted. I feel as though va_args might be up the right alley, but they seem like a really messy solution. What would work best here?