Skip to main content
gamedev.net
🔒 Locked

Inline functions

Started by Digital Extent Dec 26, 2002 at 3:40 PM 2 replies 250+ views
Original Post
Digital Extent
Digital Extent
Just wonder, how often do you use inline functions. And if you do, what is the specific reason?
Programming is easy, thinking is hard.
Waverider
Waverider
The compiler will attempt to assemble the program such that the function executes and returns its results without an actual function call, instead working the function code into the block where it is being called.

Which speeds up execution (one reason), but also increases the size of your executable.

How often? As often as the above reason is important enough to make use of it.
It's not what you're taught, it's what you learn.
Digital Extent
Digital Extent
Can the compiler recognize inline functions if they are declared in the .cpp file compiled into a .lib file?
Programming is easy, thinking is hard.
athos_musketeer
athos_musketeer
the inline function must be declared in the .h (that says microsoft in vc++ 6.0)

you should use inline functions in small functions that you call very often; a good example is a get/setValue in a class.

inline void Class::getState(){
return state}

you get the point. don''t you?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.