![]() |
| | #1 |
| Registered User Join Date: Oct 2001
Posts: 11
| Pointer & reference e.g.: int K; int*p=&k ; &ref=k; (both *p=20; and ref=20; will assign the value 20 into the variable k) thanks for ur time and help. ~ayesha~ |
| ayesha is offline |
| | #2 |
| Registered User Join Date: Oct 2001
Posts: 28
| The "Cliff Notes" version of your question is a reference is a pointer but with less versatility. The reference is simpler and easier to use. A reference variable cannot be altered to refer to any variable except the one to which it was initialized. A reference passed to another function is preferred if possible because while the receiving function has a copy of the value in the address passed, it cannot change the value in the original function. Thus protecting the original value. References cannot be used for array notation.
__________________ rc7j |
| rc7j is offline |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting an error with OpenGL: collect2: ld returned 1 exit status | Lorgon Jortle | C++ Programming | 6 | 05-08-2009 08:18 PM |
| Using Vectors. MinGW warning | Viewer | C++ Programming | 9 | 03-26-2009 03:15 PM |
| Undefined Reference Compiling Error | AlakaAlaki | C++ Programming | 1 | 06-27-2008 11:45 AM |
| C OpenGL Compiler Error? | Matt3000 | C Programming | 12 | 07-07-2006 04:42 PM |
| Pass by pointer, reference, value. | Lithorien | C++ Programming | 8 | 02-25-2005 10:03 AM |