I'm trying to create a graph class that is implemented as an array of pointers. This array is dynamically allocated which is where i'm having my trouble. I'm getting an error message from my equal signs saying that the operator doesn't exist
GraphClass::~GraphClass()
{
Node *temp;
temp = array;
Node *temp2;
temp2 = temp;
if(array == NULL)
return;
else
{
for(int i = (arraysize - 1); i >= 0; i--)
{
temp2 = temp[i];
while (temp2!=NULL)
{
temp[i] = temp[i].next;
delete temp2;
temp2 = temp[i];
}
}
}
}
GraphClass::GraphClass(int k)
{
int i;
array = new Node*[k];
Node *temp = array;
for(i = 0; i < k; i++)
{
array[i] = NULL;
}
arraysize = k;
}
in my class array is a pointer to a Node. like i said i'm getting an error every time i try to use temp...anyone have any ideas?
here are the exact errors i'm getting
C:\Program Files\Microsoft Visual Studio\MyProjects\graphs\GraphClass.cpp(22) : error C2440: '=' : cannot convert from 'struct Node ** ' to 'struct Node *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\graphs\GraphClass.cpp(31) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct Node' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\graphs\GraphClass.cpp(34) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct Node *' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\graphs\GraphClass.cpp(36) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct Node' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\graphs\GraphClass.cpp(46) : error C2440: 'initializing' : cannot convert from 'struct Node ** ' to 'struct Node *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast