Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 7: Functions > Parameter Passing Modes

Parameter Passing Modes

Function declarations specify a list of parameters, or formal arguments. At the call site, the source code location where the function is invoked, a name of the function to call is followed by a parenthesized list of corresponding actual arguments. The types passed to a function must match the formal list of arguments types declared at the function.

int myFunc( int j )     // 'j' is a formal argument
{
   return j + 10;
}

myInt = myFunc(5);      // the literal '5' is an actual argument

packetC parameters can be passed in two modes:

  • By value: the value of each actual argument is copied to the corresponding formal argument.
  • By substitution: the function being called is inlined; each actual argument accompanied by the “@” symbol is substituted into the inlined function's body to replace each instance of the corresponding formal argument. packetC supports by-substitution parameters that are constants, expressions, and const variables if the called function does not assign values to the corresponding formal argument.

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial