Search code examples
c++unreal-engine5

Unreal Engine 5 C++ - initializing class doesnt work


Hey I'm currently trying to debug my game but whenever I try i get the following errors: "syntax error: missing ';' before '*'" -> line 30 of my code and "missing type specifier - int assumed. Note C++ does not support default-int" -> line 30 aswell "unexpected token(s) preceding ';'" -> also on line 30

My code looks like this:

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

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "GameFramework/SaveGame.h"
#include "MyDataConfig.h"
#include "AbilityConfig.h"
#include "QuestsConfig.h"
#include "PlayerHUDCpp.generated.h"


UCLASS()
class WOWFAKECPP_API UPlayerHUDCpp : public UUserWidget
{
    GENERATED_BODY()



public:

    bool target = false;
    int DisplayedQuest = 0;
    bool QuestOpen = false;
    //FString accept = "Accept";

    UQuestsConfig* MyQuestConfig;
    UMyDataConfig* MyDataConfig;
    UAbilityConfig* MyAbilityConfig;

The last line is line 30. As you can see the classes above "UAbilityConfig* MyAbilityConfig;" work but the last doesnt...

I tried cleaning the project, deleted the "saved" and "intermediate" folder and restartet my pc multiple times but none of them seem to work because as soon as I try debugging the project I get the errors I showed above I don't know what I should do anymore, please help me.


Solution

  • If that is your "all code" for that file, then you are clearly missing ending bracket }.

    It should look like this:

    // Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "CoreMinimal.h"
    #include "Blueprint/UserWidget.h"
    #include "GameFramework/SaveGame.h"
    #include "MyDataConfig.h"
    #include "AbilityConfig.h"
    #include "QuestsConfig.h"
    #include "PlayerHUDCpp.generated.h"
    
    
    UCLASS()
    class WOWFAKECPP_API UPlayerHUDCpp : public UUserWidget
    {
        GENERATED_BODY()
    
    
    
    public:
    
        bool target = false;
        int DisplayedQuest = 0;
        bool QuestOpen = false;
        //FString accept = "Accept";
    
        UQuestsConfig* MyQuestConfig;
        UMyDataConfig* MyDataConfig;
        UAbilityConfig* MyAbilityConfig;
    }