• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Diff. between pointers and references.

Could any one explain me the difference beetween pass by pointer and pass by referenece. Is there any?

diff between

void f(int& r) {

void f(int* p) {

1 Solution
5 points? Bah....

When you pass like int& r you are passing the address of that variable, not the value.

When you pass like int* p you are passing the value of that variable. That is just like int p.

The time to use int* p is when you have a variable that is the address of another variable (as in it was passed via the int& r) and you need to pass it as the value of that variable, not the address.

Featured Post

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now