x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Newbie] C++ Syntax

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.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 21 '15 at 02:09 PM in C++ Programming

avatar image

WaspSix
8 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Oct 21 '15 at 02:27 PM

avatar image

Daniel Ricci
191 4 7 16

avatar image Daniel Ricci Oct 21 '15 at 02:29 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Oct 21 '15 at 02:23 PM

avatar image

MiKom
535 17 9 39

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question