![]() |
| | #1 |
| Tha 1 Sick RAT Join Date: Dec 2003
Posts: 267
| clarification I've just decided to add C# to my repetoire so I'm going through the language at the moment to iron out the differences between in and c++. At the moment I just need to clarify the value parameter of a method with perhaps an explanation of what's actually happening at the memory level: Code: IntHolder first = new IntHolder(); first.i=5; IntHolder second = first; first.i=6; Console.WriteLine (second.i); Output: 5 Now normally I would've thought that would produce a 6 since IntHolder second = first is a reference to the same object.
__________________ A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside |
| WDT is offline | |
| | #2 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,125
| IntHolder is a struct, which means value type (no referenses). Had it been a class the output would be 6.
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| srand() Clarification | Epo | C++ Programming | 2 | 03-03-2005 11:05 PM |
| Need a clarification here | bithub | A Brief History of Cprogramming.com | 30 | 12-27-2004 01:06 AM |
| exercise clarification truth table | curlious | C++ Programming | 1 | 12-18-2003 07:28 PM |
| A little clarification? | Dr Nick | C++ Programming | 2 | 06-20-2002 01:47 PM |
| Clarification of Function Templates | biosx | C++ Programming | 2 | 02-20-2002 11:42 AM |