answersLogoWhite

0

Parameters are the formal arguments of a function, as defined by the function. When you pass arguments to a function, those arguments are assigned to the function's parameters, either by value or by reference, depending on how the parameters are declared in the function. The following example explains both:

void foo( int param )

{

// param is a by value parameter, which is a copy of the argument passed to it.

}

void bar( int& param )

{

// param is a reference parameter, which references the argument passed to it.

}

int main()

{

int arg = 100;

foo( arg );

bar( arg );

return( 0 );

}

Note that passing a pointer is the same as passing an int by value: the pointer's value is passed to the function, not the pointer itself. To pass a pointer by reference, you must pass a pointer to pointer and the function's parameter must accept a pointer to pointer.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you create functions with multiple parameters in C plus plus?

Random example, function with two parameters: int main (int argc, char **argv) {...}


What is manipulator in c plus plus language?

Manipulators are functions that change the formatting parameters on character streams.


C plus plus program using function min that take three parameters of type int and returns the minimum of the three?

int min (int a, int b, int c) {if (a


What is the smallest number of formal parameters that can be included in a function definition in C?

You can have a function with no parameters.


Use of int in C plus plus?

Is quite common. Example: int main (int argc, char **argv) { printf ("Number of parameters is %d\n", argc-1); return 0; }


In most modern programming languages such as Java and C plus plus what are parameters in the header separated by?

I won't tell you, but maybe this example helps: int myfunction (int param1, long param2, short param3)


What is the basic parameters of transmission lines?

the basic parameters of transmission lines are R,L,C and G...........


What is true about the parameters of a function (Python 3)?

a. Functions can have only one parameter. b. The order in which the parameters are defined matters. c. Parameters can be passed to a function in any order. d. Parameters have no order.


What is b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c


What is c plus c plus 2c plus c plus c equal?

c + c + 2c + c + c = 6c


B plus b plus b plus c plus c plus c plus c equals?

b + b + b + c + c + c + c = 3b + 4c


Symplify c plus c plus c plus c?

4c