Trying to override base class methods, getting error C3668

I was following survival sample game tutorial about Sprinting and sharing it to all clients. And I am trying to use same method for my character but trying to put combat mode on

I use parent character to define all inputs and put the combat mode on and then im using Base character to set it on to other clients.

The problem is that this

virtual void SetCombatMode(bool NewCombatMode) override
{
}

should override this

virtual void SetCombatMode(bool NewCombatMode);

but when trying to compile it says this error

error C3668: 'AFpCharacter::SetCombatMode': method with override specifier 'override' did not override any base class methods

here is my both characters classes

parent character .h

#include "BaseFpCharacter.h"
#include "FpCharacter.generated.h"

void C_ModeToggle();

virtual void SetCombatMode(bool NewCombatMode) override
{
}

parent character .cpp

#include "FP_Duel.h"
#include "FpCharacter.h"
#include "engine.h"
#include "BaseFpCharacter.h"

void AFpCharacter::C_ModeToggle()
{
	SetCombatMode(true);
}

and Base character .h

#include "project.h"
#include "Net/UnrealNetwork.h"
#include "BaseFpCharacter.generated.h"

public:

UFUNCTION(BlueprintCallable, Category = "Movement")
	virtual bool IsCombatMode() const;

	virtual void SetCombatMode(bool NewCombatMode);

UPROPERTY(Transient, Replicated)
	bool bWantsCombatMode;

protected:

	UFUNCTION(Reliable, Server, WithValidation)
	void ServerCombatMode(bool NewCombatMode);
	void ServerCombatMode_Implementation(bool NewCombatMode);
	bool ServerCombatMode_Validate(bool NewCombatMode);

	virtual void Tick(float DeltaSeconds) override;

base character .cpp

    #include "BaseFpCharacter.h"
    #include "DuelGameMode.h"

void ABaseFpCharacter::SetCombatMode(bool NewCombatMode)
 {
    bWantsCombatMode = NewCombatMode;
    
    if (Role < ROLE_Authority)
    {
    ServerCombatMode(NewCombatMode);
    }
}

    void ABaseFpCharacter::Tick(float DeltaTime)
    {
    
    Super::Tick(DeltaTime);
    
    if (bWantsCombatMode && !IsCombatMode())
    {
    SetCombatMode(true);
    }
    
}

Thanks for help

Did you specify that your AFpCharacter inherit from ABaseFpCharacter ?

in AFpCharacter.h

class AFpCharacter: ABaseFpCharacter
{
public:
   ....

}

It’s tough to see what’s going on without the full contents of the source files. You say you want AFpCharacter to be the “parent”, but if it’s the parent then ABaseFpCharacter should be overriding its methods, not the other way around. Do you mean that AFpCharacter is supposed to be the child?

If this is the full content of the source files, there’s a number of problems here. Without the class declarations there’s no tie into your API, UE4 macros, or Blueprints (if you want access to them in Blueprints); on top of the fact that you’re not actually creating a new class.

Your method definition in the FpCharacter.h file is declaring an empty method within the header; you can place it here, but you probably just want a semi-colon (:wink: after “override” and to place the body of the function (assuming there is one) in the .cpp file.

So this:

#include "BaseFpCharacter.h"
 #include "FpCharacter.generated.h"
     
 void C_ModeToggle();
     
 virtual void SetCombatMode(bool NewCombatMode) override
 {
 }

Should look more like this:

#include "BaseFpCharacter.h"
#include "FpCharacter.generated.h"
         
UCLASS()
class YOURGAME_API AFpCharacter : public ABaseFpCharacter {
    
    GENERATED_BODY()
    
    //constructor
    AFpCharacter();
    
    void C_ModeToggle();
    
    virtual void SetCombatMode(bool NewCombatMode) override;
    
};

If you want your class to be available in Blueprint you’ll want to include “Blueprintable” and “BlueprintType” in your UCLASS macro:

UCLASS(Blueprintable, BlueprintType)

Your FpCharacter.cpp file should go from this:

#include "FP_Duel.h"
 #include "FpCharacter.h"
 #include "engine.h"
 #include "BaseFpCharacter.h"
 
 void AFpCharacter::C_ModeToggle()
 {
     SetCombatMode(true);
 }

To this:

 #include "FP_Duel.h"
 #include "FpCharacter.h"
 #include "engine.h"
 #include "BaseFpCharacter.h"
 
//Constructor
AFpCharacter::AFpCharacter()
    :
    ABaseFpCharacter()
{}

void AFpCharacter::C_ModeToggle()
 {
     SetCombatMode(true);
 }

void AFpCharacter::SetCombatMode(bool NewCombatMode)
 {
    //include method functionality here; assuming you want to do
    //something with the boolean;

    //if you want to add to the functionality of the parent method
    //rather than replacing it, be sure to include:
    Super::SetCombatMode(NewCombatMode)

 }

Similarly, your BaseFpCharacter needs a class declaration, macros etc. I’m assuming you want to inherit from ACharacter, but you could also use APawn or AActor

#include "project.h"
#include "Net/UnrealNetwork.h"
#include "BaseFpCharacter.generated.h"

UCLASS(Blueprintable, BlueprintType)
class YOURGAME_API ABaseFpCharacter : public ACharacter
{
    GENERATED_BODY()

    public:

    //constructor
    ABaseFpCharacter(); 

    UFUNCTION(BlueprintCallable, Category = "Movement")
    virtual bool IsCombatMode() const;
     
    virtual void SetCombatMode(bool NewCombatMode);
     
    UPROPERTY(Transient, Replicated)
    bool bWantsCombatMode;
 
    protected:
     
    UFUNCTION(Reliable, Server, WithValidation)
    void ServerCombatMode(bool NewCombatMode);
    void ServerCombatMode_Implementation(bool NewCombatMode);
    bool ServerCombatMode_Validate(bool NewCombatMode);
     
    virtual void Tick(float DeltaSeconds) override;

};

Then your BaseFpCharacter.cpp fill will need to include the constructor:

ABaseFpCharacter::ABaseFpCharacter()
    :
    ACharacter()
{}

sorry I should have said that I had all Constructors. problem was the FpCharacter.h header

UCLASS()
class FP_DUEL_API AFpCharacter : public ABaseFpCharacter
{
	GENERATED_BODY()