Instructors input parameters change after copy/paste

I’ve noticed that when Stephen copy-pastes his function declaration from the header file over to the cpp file that the input parameters of the function change slightly.

For example, the declared function is as follows:

void DamageTaken(AActor* DamagedActor, float Damage, const UDamage* DamageType, class AController* Instigator, AActor* DamageCauser)

But when he copies and pastes it to the CPP file, it becomes as follows:

void UHealthComponent::DamageTaken(AActor *DamagedActor, float Damage, const UDamage *DamageType, class AController *Instigator, AActor *DamageCauser)

Why do the ‘*’ symbols move to the front of the variable name automatically? And how do I turn that on in VSCode so it’ll do the same for me? I’ve had several instances now where I’ve got a compile error because I copy-pasted my function declaration over to the CPP file as a way to quickly start on my definition but didn’t have this happen automatically, so I didn’t know what was wrong. Had to rewatch the video and caught the detail that there was a change between the copy/pasting action.


Because of the code formatting feature of VS Code

It’s widely regarded that the * should be next to the type not the variable by C++ developers, because it’s part of the type.

This seems like you think the position of the * matters, it does not.

int* ptr;
int * ptr;
int *ptr;

All 3 of these mean the same thing, that ptr is a pointer to int.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms