C++ const problem

Hõiva
I have a problem with the Vector variable and const.
The Vector gives an error “C++ variable is not a type name”
The Vector gives an error “C++ a type qualifier is not allowed on a nonmember function”

Also I have found out that creating the variable inside the function for some reason works.

Hõiva2

Hõiva3

Would like to just know how to fix the errors. Thanks.

Why are you declaring a function inside another function? It’s not supported. You have to declare a function in .h, or use a lamdba if inside another function.

What exactly are you trying to do?

Instead of calling your function in the foreach loop you copied it’s definition.
try

for (FVector Vector : LocationSet) {
	AddGeneratedVector(Vector);
}

You already have the const in your header definition, don’t repeat it on function call.

1 Like

I tried it already, but the function is const.


The function is made by Epic Games and I cant change it either.

It doesn’t matter to you if the function is const when you call it. const only affects what’s going on inside that function.
What @3dRaven posted must work. However, make sure you’re calling AddGeneratedVector for the right object.

Now the error is “C++ incomplete type is not allowed” I tried using “&” but that didnt help.

Also when I copied the function and but it in my own class it dosnt give any errors.
The “GenerateVector” is copied.

Get rid of the void when you are calling the function.

I accidentally left the void there, but still the function is now undefined evethough I have the correct headerfail from the documentation.
Hõiva

Documentation

What is this class that you’re working in? Is it derived from UEnvQueryGenerator_BlueprintBase?