Inline Functions versus Macros


#include <iostream.h>
#include<conio.h>
#define sqr(a) a*a            // Macro definition
inline int square (int a)        // inline function definition
{
    return (a*a);
}
void main(void)
{
    clrscr();
    cout << "Square(10)  = " << square(10);
    cout << "\nSquare(10+10) = " << square(10+10);
    cout << "\nSqr(10)  = " << sqr(10);
    cout << "\nSqr(10+10) = " << sqr(10+10);
    getch();
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|