Struct Constructor with Argument

I can’t find where I went wrong myself, so I was wondering if you guys can catch my error.

I have a USTRUCT set up as such:

struct FMyStruct
{
	float MyVar = 1.0f;
	float MyOtherVar = 1.001f;

	FMyStruct()
	{

	}

	FMyStruct(float Var = 1.0f)
	{
		MyVar = Var;
		MyOtherVar = Var;
	}

	FMyStruct(float VarA = 1.0f, float VarB = 1.0f)
	{
		MyVar = VarA;
		MyOtherVar = VarB;
 }

In a class header, I have this:

UPROPERTY()
	FMyStruct MyStructo = FMyStruct(1.4f);

However, I get a compiler error:

error C2440: '<function-style-cast>': cannot convert from 'float' to 'FMyStruct'

Intellisense also complains that I have “more than one instance of constructor MyStruct::MyStruct matches the argument list.”

What am I missing here?

Does it build?

In VS Community, no, on account of the same error that Intellisense gives me.

Have you tried removing the default values for the parameters in the other constructors? You’re already defaulting the struct variables to 1.0f anyway.

Hey, that did it. I guess it didn’t like me setting default values. Thanks!

I think adding default values to the arguments makes them optional, and since all their arguments are optional, they all look the same. If you did FMyStruct() without any values input, it wouldn’t know which constructor to use.