Why does CreateWidget c++ version not behave the same as Create Class BP function?

So basically you just call the AddToViewport function after creating your widget with the CreateWidget function. Here’s some code I’m using myself.



	if (UMGScoreboardClass)
	{
		scoreboard = CreateWidget<UScoreboardWidgetBase>(this, UMGScoreboardClass);
		scoreboard->AddToViewport();
        }