A function is declared inline by using the inline function specifier or by defining a member function within a class or structure definition. The inline specifier is only a suggestion to the compiler that an inline expansion can be performed; the compiler is free to ignore the suggestion. The following code fragment shows an inline function definition.View more random threads:
- forward declaration instead of header files in c++ 2011
- explain error handling in c++ 2011
- vector index problem in c++ 2011
- binary tree,the pre and post order traversal have the same...
- can we define objects without any class?
- Why we use iostream.h in our program?
- In C++ is SPACE is also a charactor??
- Multidimensional Array vs If-Statements and Functions? in...
- how i can write a right program without any errors n i do...
- In aggregation we use a pointer e.g. like chair object in a...
inline int add(int i, int j)
{
return i + j;
}
An inline function is one for which the compiler copies the code from the function definition directly into the code of the calling function rather than creating a separate set of instructions in memory. Instead of transferring control to and from the function code segment, a modified copy of the function body may be substituted directly for the function call. In this way, the performance overhead of a function call is avoided.
A symbol, name, or key that represents a list of commands, actions, or keystrokes. Many programs allow you to create macros so that you can enter a single character or word to perform a whole series of actions. As in the following example we are defining a macro with named PI and it will be replaced by the constant value 3.1415926 wherever PI is used in the program.
#define PI 3.1415926
Here the symbol PI will be replaced with the actual value (i.e. 3.1415926) in the program. These are simple macros like symbolic names mapped to constants.
Sponsored Links
There are currently 1 users browsing this thread. (0 members and 1 guests)