[Newbie] C++ Syntax

class UStaticMeshComponent* is a type returned by this function. class keword here doesn’t mean definition of new class but is rather a forward declaration. const qualifier says, that this method doesn’t change the contents of the class (has no external effect) and can be called also on const instances of this class.

Hello Unreal community, I was hoping someone out there would be able to help me with some C++ Syntax since I’m coming from Unity where I used the much easier C# language.

I have been following tutorials where I can and I’ve been using the Battery Collector 3 tutorial which shows this line in the header file, FORCEINLINE class UStaticMeshComponent* GetMesh() Const {}

Now I believe I know what force inline does which is creates a copy of it to reduce overhead of calls but what confuses me is that this has the class and const keywords but looks like a function then looks like a pointer?

Could anyone explain to an idiot like me in easy to understand terms please?

Thank you very much.

Just as a heads up first.

FORCEINLINE class UStaticMeshComponent* GetMesh() const {}

is the same as writting

inline UStaticMeshComponent* GetMesh() const {}

inline or its equivalently deprecated UE macro simply replaces all function calls with the actual definition of the function, so what this does is it reduces the overhead of calling a function and the time it takes.

“class” inside of the function declaration is used to prevent potential name clashes, I rarely see this outside of UE but it can be used to solve this problem. There is an MSDN article that talks a bit more about this, if I find it I’ll link it here.

const at the end of the function states that the function wont alter the state of any of the data members of the passed in instance, you would put this on things like getters, but any class function that will not change the state of the object should have this const keyword

Also as a heads up, I’ve obviously skimmed over the technical jargon, this should at least answer your question without having you google other terms.