Thursday, June 25, 2009

A function can be declared inline



NOTE : -
THIS CONTENT IS NOT ORIGINAL

10. A function can be declared inline

If a function contains just simple lines of code, doesn't use for loops or the like, it can be declared inline. This means its code will be inserted everywhere the function is used. That's somewhat like a macro. The main advantage is the program will be faster. A small drawback is it will be bigger, because the full code of the function was inserted everywhere it is used:


using namespace std;
#include
#include

inline double hypothenuse (double a, double b)
{
return sqrt (a * a + b * b);
}

int main ()
{
double k = 6, m = 9;

// Next two lines produce exactly the same code:

cout << hypothenuse (k, m) << endl;
cout << sqrt (k * k + m * m) << endl;

return 0;
}


Output
10.8167
10.8167



(Inline functions have been added to C in C99 and ANSI C 2000.)




BIBILOGRAPHY / REFERENCE : - http://www.4p8.com/eric.brasseur/cppcen.html

No comments:

3G S

JAIL BREAK

iPHONE

BILL GATES

StEvE JoBs

steve jobs

STEVE JOBS

Steve Jobs

Love Country

SD

Burroughs

Lift

Joseph Johnson

Apple Rainbow

Apple Blue

Apple Laser Printer