Struct in my header is undefined in my Cpp file

I have a class header that contains this struct in it, and i even have a function that the uses the struct type without any problem.


struct QuestElement
	{
		TArray<FString> mainElement;
		TArray<FString> argument;
	};

QuestElement getElementFromString(const FString element);


But as soon as I move to my CPP file it says that it is undefined, I get this errors:



Error (active) declaration is incompatible with "QuestParser::QuestElement QuestParser::getElementFromString(FString element)" (declared at line 27 of "c:\...\Quest\QuestParser.h")17

Error	C4430 missing type specifier - int assumed. Note: C++ does not support default-int C:\...\Quest\QuestParser.cpp	18


From the errors, it’s assuming QuestElement is an int or it is out of scope for some unknown reason to me.

Please show your CPP code for implementation of function getElementFromString(FString element)

Also if there are no problems use a USTRUCT

That would amount to

USTRUCT()
struct FQuestElement
{
GENERATED_BODY()
TArray<FString> mainElement;
TArray<FString> argument;
};

Here is the code for that function:



QuestElement QuestParser::getElementFromString(const FString element)
{
	QuestElement* qElement = new QuestElement();

	//  Elements are separeted by comas, so if there is "," in the FString it means it has multiple elements
	if (element.Contains(","))
	{
		//  This will FString will contain the value of the split;
		FString stringA, stringB;

		// Loop while there is more elements
		do
		{
			element.Split(",", &stringA, &stringB);
			qElement->mainElement.Add(stringA);

			//  If there is no more element add stringB to the array.
			if(!stringB.Contains(","))
				qElement->mainElement.Add(stringB);

		} while (stringB.Contains(","));
	}

	return qElement;
}


The error I get is that QuestElement is underfined, but qElement is fine, and the return type does match. I’ve highlight them in read.

Your struct is nested within another class. Not sure if that’s intended.

If that IS intended, return value should be written as:



QuestParser::QuestElement QuestParser::getElementFromString(const FString element)


Keep in mind that USTRUCT/UCLASS do not support nested types.

Your struct is nested within another class (you declared QuestElement within QuestParser). Not sure if that’s intended.

If that IS intended, return value should be written as:



QuestParser::QuestElement QuestParser::getElementFromString(const FString element){
}


Keep in mind that USTRUCT/UCLASS do not support nested types.

Yeah I had a struct nested with a class, I move it out and I don;t have any more issue. Thanks alot.