Presentation is loading. Please wait.

Presentation is loading. Please wait.

A simple function.

Similar presentations


Presentation on theme: "A simple function."— Presentation transcript:

1 A simple function

2 1. Call by Value

3 1. Call by Value

4 2. Call by address

5 2. Call by address

6 Pointer Example : 1

7 Example of a simple Reference

8 Example of Reference in a function

9 3. Call by Reference

10 3. Call by Reference

11 2.1  References (or Aliases) (&)
Recall that C/C++ use & to denote the address-of operator in an expression. C++ assigns an additional meaning to & in declaration to declare a reference variable. The meaning of symbol & is different in an expression and in a declaration. When it is used in an expression, & denotes the address-of operator, which returns the address of a variable, e.g., if number is an int variable, &number returns the address of the variable number (this has been described in the above section). Howeve, when & is used in a declaration (including function formal parameters), it is part of the type identifier and is used to declare a reference variable (or reference or alias or alternate name). It is used to provide another name, or another reference, or alias to an existing variable. The syntax is as follow:

12 References

13

14

15


Download ppt "A simple function."

Similar presentations


Ads by Google