Solved
Question on pointers
Posted on 2003-03-19
Hi..
I have arrays of pointers given by:
static Node * nodeArray = NULL;
static Edge * edgeArray = NULL;
and I initialized the arrays as :
nodeArray = new Node[<some integer>];
edgeArray = new Edge[<some integer>];
I defined the 'Edge' class like this:
#include "Node.cpp"
class Edge
{
public:
Edge();
Edge(Node &N1, Node &N2);
Node *leftNode;
Node *rightNode;
float length;
bool isIncluded;
};
Edge::Edge()
{
}
Edge::Edge(Node &N1, Node &N2)
{
isIncluded = false;
leftNode = &N1;
rightNode = &N2;
length = N1.distanceTo(N2);
}
When I am trying to create an instance of 'Edge' in the edgeArray like this:
edgeArray[<some integer>] = new Edge(nodeArray[xCount],nodeArray[yCount]);
I am getting an error saying that:
no match for `Edge& = Edge*&' operator
Edge.cpp:5: candidates are: Edge& Edge::operator=(const Edge&)
I am not able to figure out what went wrong in my code. I would appreciate if you can help me in this.
Thanks,
SJ.