missing type specifier - int assumed error

Hello guys, i created a struct


Then i created variables of this struct in player character class
image
And after that i got error “missing type specifier - int assumed error. Note: C++ does not support default int”
P.S: c++ script where ustruct is located included in cpp file of player char class

How to fix this error? Please someone help me!

#pragma once

#include "CoreMinimal.h"
#include "CapsuleValues.generated.h"


USTRUCT(BlueprintType)
struct FCapsuleValues
{
	GENERATED_BODY()
public:
	UPROPERTY(EditAnywhere,BlueprintReadWrite)
	float Height;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float Radius;

	FCapsuleValues() {};

	FCapsuleValues(float H, float R) {
		Height = H;
		Radius = R;
	}

};

and implementation in character example

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "CapsuleValues.h"
#include "MyCharacter.generated.h"



UCLASS()
class GAME_API AMyCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AMyCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

protected:

	FCapsuleValues CapsuleValuesCrouch;
	FCapsuleValues CapsuleValuesNonCrouch;

};

You need a parameter-less version of the constructor as you are not passing in the height and radius in the uninitialized parameters (so default parameter-less is normally called)

2 Likes

You can also provide default parameters to the existing constructor.

FCapsuleValues(float H = 1.0f, float R = 1.0f) {
	Height = H;
	Radius = R;
}
1 Like