# How do I set Default Value for a member variable in C++?

**URL:** <https://forums.unrealengine.com/t/how-do-i-set-default-value-for-a-member-variable-in-c/2711229>\
**Category:** Programming & Scripting\
**Tags:** variables, default-value, unreal-engine, CPP, question\
**Created:** [April 3, 2026, 1:45pm UTC](https://forums.unrealengine.com/t/how-do-i-set-default-value-for-a-member-variable-in-c/2711229 "2026-04-03T13:45:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pagi111](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pagi111](https://forums.unrealengine.com/u/pagi111)\
**Post date:** [April 3, 2026, 1:45pm UTC](https://forums.unrealengine.com/t/how-do-i-set-default-value-for-a-member-variable-in-c/2711229/1 "2026-04-03T13:45:19Z")

</div>

Hi,  
So, if I create a variable in BP, under Details there is the Default Value that we can specify. If this is a var that is Instance Editable, and its value is changed, a small icon appears that allows to reset it to the default value.

![Zrzut ekranu 2026-04-03 152745](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/b/95bbc33fd2db681012a297a35b5ca0011c374a71.png)

How do I do that in C++? To make my question clear: what do I do with the variable in C++, if I want it to have a default value and when this value is changed, I want this ‘reset to default value arrow’ icon to appear in BP.

If that matters, my C++ class variable is of a UStruct type that contains some **bool** as well as **FSlateBrush** variables. I would like these variables to have default values.

---

<div class="post-metadata">

**Author:** ![PREDALIEN](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/predalien/32/1194670_2.png) [@PREDALIEN](https://forums.unrealengine.com/u/PREDALIEN)\
**Post date:** [April 3, 2026, 3:01pm UTC](https://forums.unrealengine.com/t/how-do-i-set-default-value-for-a-member-variable-in-c/2711229/2 "2026-04-03T15:01:32Z")

</div>

🤔 Just specify the default value in the code (?)

```auto
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int MyVar = 100500;

```

---

<div class="post-metadata">

**Author:** ![pagi111](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pagi111](https://forums.unrealengine.com/u/pagi111)\
**Post date:** [April 4, 2026, 6:44am UTC](https://forums.unrealengine.com/t/how-do-i-set-default-value-for-a-member-variable-in-c/2711229/4 "2026-04-04T06:44:10Z")

</div>

Ok, so the problem possibly is that my variable is a UStruct:

```cpp
USTRUCT(BlueprintType)
struct FCommonButtonStyleOverride
{
	GENERATED_BODY()

public:
	FCommonButtonStyleOverride() { bOverrideBaseNormal = false; BaseNormal = FSlateBrush();}
	
	/** Should this button override the Style's Base (not-Selected/not-Disabled) Normal (not-Hovered, not-Pressed) state */
	UPROPERTY(EditAnywhere, BlueprintReadWrite) bool bOverrideBaseNormal;
	/** The Base (not-Selected/not-Disabled) Normal (not-Hovered, not-Pressed) state brush to apply if the corresponding override is True */
	UPROPERTY(EditAnywhere, BlueprintReadWrite) FSlateBrush BaseNormal;
...

```

As you can see I made the constructor for the Struct (which I’m not even sure is necessary).

Then, I declared my variable like this:

```cpp
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Style)
FCommonButtonStyleOverride StyleOverride;

```

I also tried like this:

```cpp
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Style)
FCommonButtonStyleOverride StyleOverride = FCommonButtonStyleOverride();

```

None of these worked.  
EDIT: I also tried specifying the default value in, while declaring the variable in the struct - didn’t work either.

What’s more, I tried making a simple bool variable and set it to true, when declaring it, exactly as you suggested - it doesn’t work:

```cpp
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Style)
bool StyleOverrideBool = true;

```

![Zrzut ekranu 2026-04-04 093550](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/e/a9e7b099259228dca0b54f2764276a1c907edf88.png)

![Zrzut ekranu 2026-04-04 093626](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/a/dca2b62998028e17b2e994f633077690ef2d32b3.png)

No ‘reset to default value arrow’ icon appears, regardless if I set it to true or false.
