-1

Possible Duplicate:
What are the differences between pointer variable and reference variable in C++?
Pointer vs. Reference

I recently started to 'relearn' c++ and encountered a simple question that i always had.

Int *intp = new int(10);
Int& intref = *intp;

intref prints as 10 *intp does so too.

Also do the prints of &intref and intp equal.

Long story short. Is the difference between & and * simply the way you access the value and adress? Or is there a major difference in usage?

Community
  • 1
  • 1
billdoor
  • 1,999
  • 4
  • 28
  • 54
  • Those duplicates are far superior questions. In this one, the example doesn't even compile. And what is "print"? `cout` or `printf`? – Mr Lister Jan 26 '13 at 12:02

1 Answers1

1

The * notation means what's being pass on the stack is a pointer, ie, address of something. The & says it's a reference.

Refer this Thread

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331