'Rotate': illegal qualified name in member declaration

I am having an issue in TankTurret.cpp on Complie as it is claiming that Rotate is an illegal qualified name, I’ve compared my Code to the GitHub commit and its exactly the same.

Unreal Engine: 4.24
Visual Studio 2019 (Latest version)

I also compared it to my TankBarrel files and the same includes are there that I needed to add previously, I have no idea whats going on and Intellisense even says its fine:

#pragma once

#include "CoreMinimal.h"
#include "Battle_Tank.h"
#include "Components/StaticMeshComponent.h"
#include "TankTurret.generated.h"

/**
 * 
 */
UCLASS(meta = (BlueprintSpawnableComponent), hidecategories = ("Collision"))
class BATTLE_TANK_API UTankTurret : public UStaticMeshComponent
{
	GENERATED_BODY()
public:
	// -1 is max downward speed, and +1 is max up movement
	void UTankTurret::Rotate(float RelativeSpeed);

private:
	UPROPERTY(EditAnywhere, Category = Setup)
		float MaxDegreesPerSecond = 25;
};

CPP:

#include "Battle_Tank.h"
#include "TankTurret.h"
#include "Math/UnrealMathUtility.h"

void UTankTurret::Rotate(float RelativeSpeed)
{
	RelativeSpeed = FMath::Clamp<float>(RelativeSpeed, -1, +1);
	auto RotationChange = RelativeSpeed * MaxDegreesPerSecond * GetWorld()->DeltaTimeSeconds;
	auto Rotation = RelativeRotation.Yaw + RotationChange;
	SetRelativeRotation(FRotator(0, Rotation, 0));
}

Also, I am having a strange issue where the Barrel is going up and down, but only with the camera movement, but I feel like getting Rotation working will help solve this

UTankTurret::Foo would be a qualified name.

void UTankTurret::Rotate(float RelativeSpeed);

So doing this in the class declaration is non-standard code. You aren’t allowed to qualify the names of members of the class with the class’ name like that.
Microsoft’s compiler previously allowed this which is why Ben’s compiles. Microsoft’s compiler now comforms to the C++ standard so forbids this.

I think I’ve solved it by getting rid of the UTankTurret:: part

void UTankTurret::Rotate(float RelativeSpeed);

to

void Rotate(float RelativeSpeed);

Thanks, I managed to figure it out as you posted the reply :smiley:

1 Like

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

Privacy & Terms