xjz2020
(xjz2020)
1
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataTable.h"
#include "Item.generated.h"
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
GENERATED_USTRUCT_BODY()
}
USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase, public FItem {
GENERATED_USTRUCT_BODY()
};
compile it will get error: Missing ‘{’ in ‘struct’
but the follow two case is ok.
- remove USTRUCT
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
GENERATED_USTRUCT_BODY()
}
// USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase, public FItem {
GENERATED_USTRUCT_BODY()
};
- inhert one struct
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
GENERATED_USTRUCT_BODY()
}
USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase {
GENERATED_USTRUCT_BODY()
};
Is this a bug?
jwatte
(jwatte)
2
From what I know, the Unreal header tool / macros only work for single inheritance, except for when implementing interfaces.
That being said, in general, it seldom actually works out right to inherit multiple from structs – generally, aggregation (members) works better IMO.
2 Likes
xjz2020
(xjz2020)
3
Thanks for your reply.
I would try to avoid inheriting multiple structs.
Also don’t use GENERATED_USTRUCT_BODY is deprecated and just forwards to GENERATED_BODY so use that as they may (highly unlikely) remove the old one.
2 Likes
You are getting a compile error because of the missing ‘;’ semi colon at the end of FItem.
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
GENERATED_USTRUCT_BODY()
}
xjz2020
(xjz2020)
6
Oh, sorry, because I entered the code manually.