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 broiled, float other_stuff); int main() { float y = square (6.2); return 0; } 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; } 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() int main() { { float y = 6.2 * 6.2; float y = square (6.2); return 0; return 0; } } 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 http://cs.mst.edu
End of Session http://cs.mst.edu
Recommend
More recommend