Calling ConventionCalling convention means how parameters are pushed on the stack when a function is invoked. Table 14.4 describes the calling convention method of a few languages.
Table: Calling Conventions
In C/C++, parameters are passed from right to left; whereas in other languages such as basic, FORTRAN calling convention is in order from left to right. The following program explains the calling convention of C++:
Explanation: In this program, integer variables x and y are initialized to two and three, respectively. The show() function show() is invoked, and x and y are passed as per the statement show (x, y). The parameters are passed from right to left. The variable y is passed first followed byx. The values of variables with their position in the stack are displayed in Figure.
Fig: Stack with arguments
The value of the rightmost variable is pushed first followed by other variables in sequence.