Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inline Functions.

Similar presentations


Presentation on theme: "Inline Functions."— Presentation transcript:

1 Inline Functions

2 #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; }

3 #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; }

4 #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; }

5 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

6 End of Session


Download ppt "Inline Functions."

Similar presentations


Ads by Google