reference arguments n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Reference Arguments PowerPoint Presentation
Download Presentation
Reference Arguments

Loading in 2 Seconds...

play fullscreen
1 / 5

Reference Arguments - PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on

Reference Arguments. Reference Arguments. Passing arguments by reference is a mechanism in which a reference(memory address) to the original variable, in the calling program, is passed to the function.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Reference Arguments' - khalil


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
reference arguments1
Reference Arguments
  • Passing arguments by reference is a mechanism in which a reference(memory address) to the original variable, in the calling program, is passed to the function.
  • When arguments are passed by value, the called function creates a new variable of the same type as an argument and copies the argument’s value into it.
reference arguments2
Reference Arguments
  • An important advantage of passing reference arguments is that the function can access the actual variables in the calling program.
  • When the function is called, the reference argument and the variable name, in the calling function, become synonyms for the same location in the memory.
  • We can only use variables when we are passing arguments by reference. Whereas, we can use variables as well as constant when we are passing arguments by value.
reference arguments3
Reference Arguments
  • In passing arguments with value, implicit type conversion occurs if the matched items have different data types. Whereas, with reference arguments, the matched items must have the same data type.
example
Example

void abc (int&);

void main ( )

{

int temp, x;

abc(temp);

abc(x);

cout<<temp<<endl<<x;

}

void abc(int &t)

{

cout<<"enter number=";

cin>>t;

}