Inline Functions http://cs.mst.edu #include <iostream> using - - PowerPoint PPT Presentation

inline functions
SMART_READER_LITE
LIVE PREVIEW

Inline Functions http://cs.mst.edu #include <iostream> using - - PowerPoint PPT Presentation

Inline Functions http://cs.mst.edu #include <iostream> using namespace std; float calc_iq( const float hatsize, const int age, const float num_feet); inline float square(const float x) {return x*x;} void some_other_function (char


slide-1
SLIDE 1

http://cs.mst.edu

Inline Functions

slide-2
SLIDE 2

http://cs.mst.edu

#include <iostream> using namespace std; float calc_iq( const float hatsize, const int age, const float num_feet); inline float square(const float x) {return x*x;} void some_other_function (char broiled, float other_stuff); int main() { float y = square (6.2); return 0; }

slide-3
SLIDE 3

http://cs.mst.edu

#include <iostream> using namespace std; float calc_iq( const float hatsize, const int age, const float num_feet); inline float square(const float x) {return x*x;} void some_other_function (char broiled, float other_stuff); int main() { float y = square (6.2); return 0; }

slide-4
SLIDE 4

http://cs.mst.edu

#include <iostream> using namespace std; float calc_iq( const float hatsize, const int age, const float num_feet); inline float square(const float x) {return x*x;} void some_other_function (char broiled, float other_stuff); int main() { float y = square (6.2); return 0; } int main() { float y = 6.2 * 6.2; return 0; }

slide-5
SLIDE 5

http://cs.mst.edu

When and Why

  • You will inline a function only if it is relatively

small

  • Reduces some of the overhead cost of calling a

function

  • With the function being called once, twice, or

even 1000 times, the speed up will almost certainly not be noticed

slide-6
SLIDE 6

http://cs.mst.edu

End of Session