3 ms·
Think of it as two pointers referencing the same data: Time* UTC = Time(0); Time* GMT = *UTC; *UTC == *GMT; // True UTC == GMT; // False
by thomastjeffery 9y ago
Think of it as two pointers referencing the same data:
Time* UTC = Time(0);
Time* GMT = *UTC;
*UTC == *GMT; // True
UTC == GMT; // False
- TheSoftwareGuy 9y agoYour example with pointers actually wouldn't compile, and I think the analogy you are trying to make is not accurate. On the second line you are assigning the target address of `GMT` to be the value pointed to by UTC. In other words you are trying to assign a value of type "Time" to an object to type "Pointer-to-Time". If, however you meant for that line to be: Time *GMT = UTC; it would compile fine, but then your second comparison would evaluate to true, and the whole analogy be rather pointless.
- amaccuish 9y agoThere's also not a main(), and many other things whichs mean this clearly isn't usuable C. I read it as pseudocode.
- thomastjeffery 9y agoWhat I meant was to have them both point to the same data, but be different objects. Sure, C wouldn't work that way, but it's just supposed to be pseudocode anyway.