Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how often do we require to use inline functions and macros. their importance in c++
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
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.
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.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  why we use inline function if there are simple function available, or what is the spa Vuhelper 0 22,005 05-31-2012, 01:51 AM
Last Post: Vuhelper
  Is void used only with functions? If yes than why? Vuhelper 0 2,524 11-05-2011, 05:10 PM
Last Post: Vuhelper
  Multidimensional Array vs If-Statements and Functions? in c++ Vuhelper 0 865 07-20-2011, 10:45 PM
Last Post: Vuhelper
  difference between member functions,non member functions and friend functions ? saneha 1 5,172 05-02-2011, 04:57 PM
Last Post: Vuhelper
  can we define same functions for the two or more different objects of different class saneha 1 3,310 05-02-2011, 06:48 AM
Last Post: Vuhelper
  importance of Object Oriented 2011 saneha 1 2,072 05-02-2011, 06:12 AM
Last Post: Vuhelper
  What are constant members functions in c++ 2011 saneha 1 2,110 04-29-2011, 08:18 AM
Last Post: Vuhelper
  Use of Inline Function in c++ 2011 saneha 1 4,048 04-29-2011, 08:06 AM
Last Post: Vuhelper
  what is the purpose is isopen() in main menu,difining select, move, rotate functions saneha 1 2,766 04-29-2011, 08:02 AM
Last Post: Vuhelper
  Dear sir please clear the terms i++ and i-- what are their functions? sana.pari 1 2,085 04-24-2011, 05:13 PM
Last Post: Support

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support