What are the difference between reference variables and pointers in C++?

Answer Posted / hrpynux@gmail.com

Pointers: A pointer is a variable that holds memory address of another variable. ... References : A reference variable is an alias, that is, another name for an already existing variable. A reference, like a pointer, is also implemented by storing the address of an object.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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<<"["<

2100


What are c++ templates used for?

873


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

853


What are associate containers?

808


What is the size of integer variable?

808


Explain the isa and hasa class relationships.

785


Will c++ be replaced?

822


Explain about templates of C++.

895


What is the hardest coding language to learn?

799


What is a storage class used in c++?

817


What is #include ctype h in c++?

876


Differentiate between realloc() and free().

775


Can we change the basic meaning of an operator in c++?

868


What is a unnitialised pointer?

784


What is #include cstdlib in c++?

896