Why do you seem to default to auto for your cast instead of

So I’ll start with this. In your example you used Auto ScreenPosition but, we already know why the type is so why are we having the compiler look it up again?

FVector2D ScreenPosition = FVector2D(
		ViewportSizeX * CrossHairXLocation,
		ViewportSizeY * CrossHairYlocation
	);

Another example in TankAiController

auto PlayerTank = GetWorld()->GetFirstPlayerController()->GetPawn();

We should know that getPawn is a type of APawn, or even AActor as pawn extends actor.

So long question short. Why use auto if we know the class type being return?

Curious as to what you think the use of auto is for?

Though Herb Suter has a good talk on it (28min23sec if timestamp link didn’t work)

Also your first line could be simplified to

FVector2D ScreenPosition( 
    ViewportSizeX * CrossHairXLocation,
    ViewportSizeY * CrossHairYlocation
	);

Really good talk! very informative, I like the idea of coding against the
interface vs implementation. Thanks for the video.

Yeah, the whole talk is great too :slight_smile:

Privacy & Terms