inline functions
play

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


  1. Inline Functions http://cs.mst.edu

  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; } http://cs.mst.edu

  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; } http://cs.mst.edu

  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() int main() { { float y = 6.2 * 6.2; float y = square (6.2); return 0; return 0; } } http://cs.mst.edu

  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 http://cs.mst.edu

  6. End of Session http://cs.mst.edu

Recommend


More recommend