Member function may not may not be redeclared outside its class

I got this piece of code
void AWeapon::SetOwningPawn(ApapCharacter *NewOwner)
{
if (MyPawn != NewOwner)
{
Instigator = NewOwner;
MyPawn = NewOwner;
}
}

And in “Set owningPawn” I recieve the error : member function may not may not be redeclared outside its class

Any ideas ?

  1. you’ve already declared the function inside the class definition? Use advanced find in VS to find all SetOwningPawn references in your projects source/header files.

  2. you’ve changed scope and are not defining the classes member function in same namespace as class definition.

  3. you’re including the definition more than once, check your header files and add “#pragma once” at top to make sure its only included once.

Free resources:
Microsoft
C++ Reference Wiki

tried everything but still gives me the same error :confused:

Cant say without seeing your code. But in general, in this type of situation I would simplify the situation.

Get rid of the function declaration and compile. Technically you should see all the references to it failing. One of them could be a re-definition of the function.

Or

Define the function where it’s declared in the header instead of the source file (comment out the definition in CPP). What happens when you compile than? Resolve the errors and that should be your problem.

You could just have a typo.

1 Like

ill try ty

i commented the line of code with the error , figured out the " code above" needed 1 last } :expressionless:

Looks like stupid people still walk around in this world ^^

Ty for the help tho