+ 4

What is the difference between a reference and a pointer?

23rd Mar 2017, 4:20 AM
Muhammad Hamza
Muhammad Hamza - avatar
2 Respuestas
+ 2
A pointer is a whole variable that's job is literally to just hold the reference of something. A reference is an object that, when passed as an argument (to methods and functions requesting references) can be manipulated by them globally. For example: #include <iostream> int myVar = 3; int *myPtr = &myVar; std::cout << myPtr << std::endl; // Prints the value std::cout << *myPtr; // Prints the memory location, useful for low-level business
23rd Mar 2017, 4:26 AM
Luke Wilson
Luke Wilson - avatar
0
A reference is an address While A Pointer holds a reference
23rd Mar 2017, 4:12 PM
Abhishek Arora
Abhishek Arora - avatar