Explain "passing by value", "passing by pointer" and
"passing by reference" ?

Answer Posted / sampurna pandey

i am not agree with Ranjeet, you mention this

main()
{
int i;
func(i); // call by reference
}

but fun(i) is a call by value not call by reference

your code will give compile error.

Ven eample is right.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many characters are recognized by ANSI C++?

891


Can a constructor be private?

573


Which software is best for programming?

652


Can we distribute function templates and class templates in object libraries?

583


What is an accessor in c++?

613






What is atoi in c++?

558


What is array in c++ example?

638


What is the difference between an array and a list?

579


Should I learn c or c++ first?

560


Do you know the problem with overriding functions?

564


What is the difference between *p++ and (*p)++ ?

766


What are the data types in c++?

511


What is the difference between set and map in c++?

600


how can i access a direct (absolute, not the offset) memory address? here is what i tried: wrote a program that ask's for an address from the user, creates a FAR pointer to that adress and shows it. then the user can increment/decrement the value in that address by pressing p(inc+) and m(dec-). NOW, i compiled that program and opened it twice (in 2 different windows) and gave twice the same address to it. now look what happen - if i change the value in one "window" of the program, it DOES NOT change in the other! even if they point to the same address in the memory! here is the code snippet: //------------------------------------------------------ #include //INCLUDE EVERY KNOWN HEADER FILE #include //FOR ANY CASE... #include #include #include main() { int far *ptr; //FAR POINTER!!! long address; char key=0; //A KEY FROM THE KEYBOARD int temp=0; clrscr(); cout<<"Enter Address:"; cin>>hex>>address; //GETS THE ADDRESS clrscr(); (long)ptr=address; temp=*ptr; //PUTS THE ADDRESS IN THE PTR cout<<"["<

1808


What is buffer and example?

519