Download

This declaration has no storage class or type specifier Error. Help.

I am new to programming in unreal, and am having this error “This declaration has no storage class or type specifier”. How can i fix it?

SkeletonClass.h


#pragma once

#include "UObject/Object.h"
#include "SkeletonClass.generated.h"


UCLASS(Blueprintable, BlueprintType)
class MYPROJECT3_API USkeletonClass : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SkeletonID");
int id;

USkeletonClass(const FObjectInitializer& ObjectInitializer);
UFUNCTION(BlueprintCallable, Category = "SetID")
virtual void SetID(const int& ID);
};

SkeletonClass.cpp


#include "MyProject3/MyProject3.h"
#include "SkeletonClass.h"

USkeletonClass::USkeletonClass(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
id = 0;
}

void USkeletonClass::SetID(const int& ID)
{

}

You need to post which line is giving you that error. I imagine it’s the constructor, if you’re going to use that constructor setup - you need to pass in the default argument as well when you declare the constructor



// .h
USkeletonClass(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());



Your .cpp file looks fine. If you still get the error trying adding:



#include "CoreMinimal.h"


To the top of your .h file.

Remove the “&” from the SetID function. Should be like this. Also, as far as I know you don’t have to use the ObjectInitializer anymore. It is deprecated.



UFUNCTION(BlueprintCallable)
virtual void SetId(const int32 Id);


Ok, it turns out I simply wasnt creating class the right way. To create a u-object class you have to select object class as the the parent class when youare in the unreal C++ class creation user interface. I was simply selecting “none” as the parent class. this was my problem.