supachamp@gmx.net skrev:
[color=blue]
> Hi everybody,
>
> I am having great problems with the following classes. I just can't
> figure out why I keep getting the error message:
>
> Building file: ../edge.cc
> Invoking: GCC C++ Compiler
> g++ -O0 -g3 -Wall -c -fmessage-length=0 -oedge.o ../edge.cc
> ../edge.cc: In constructor `Edge::Edge(Vertex&, Vertex&)':
> ../edge.cc:4: error: uninitialized reference member `Edge::v0'
> ../edge.cc:4: error: uninitialized reference member `Edge::v1'
>
>
> Here are the classes: (header file)
>
> class Vertex : public Object
> {[/color]
[snip][color=blue]
> };
>
> class Edge {
> protected:
> Vertex& v0;
> Vertex& v1;
> public:
> Edge(Vertex&, Vertex&);[/color]
[snip][color=blue]
> };
>[/color]
[snip][color=blue]
> Edge::Edge(Vertex& _v0, Vertex& _v1) {
> v0 = _v0;
> v1 = _v1;
> }[/color]
Edge::Edge(Vertex& _v0, Vertex& _v1):v0(_v0),v1(_v1) {}
You should strive to always construct members and base-classes directly
as the method you're using causes the default construction of these
elements. This is inefficient and - for references - downright illegal
(references must always be explicitly constructed).
[snip][color=blue]
> CQ.[/color]
/Peter