Hi, i have a simple compile time error which i cant get rid of, and was wondering if anyone can help me out.
Ok thats the error and heres the code its related to.Quote:
Compiling...
Lattice.cpp
Main.cpp
pcp2\lattice.cpp(15) : error C2440: '=' : cannot convert from 'class LatticeNode<T> *' to 'class LatticeNode<class Juxtacrine> *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\program files\microsoft visual studio\vc98\include\xmemory(59) : while compiling class-template member function '__thiscall Lattice<class Juxtacrine,500>::~Lattice<class Juxtacrine,500>(void)'
Error executing cl.exe.
PCP2.exe - 1 error(s), 0 warning(s)
The code in red is where i guess its referring to.Code:
template <class T> class LatticeNode {
public:
int num;
T t;
//next/prev nodes
LatticeNode *next;
LatticeNode *prev;
//default constructor
LatticeNode();
private:
};
template< class T, int size> class Lattice
{
public:
Lattice();
~Lattice();
int dimensions();
void remainder_cells();
void set_links();
void add(int i, int j);
void remove(int i, int j);
private:
int width, height;
LatticeNode* current;
LatticeNode* head;
LatticeNode* tail;
void init();
};
template <class T, int size> Lattice<T,size>::~Lattice()
{
LatticeNode *save;
for (current = head; current != tail; current = save) {
save = current->next;
delete current;
}
delete tail;
}
Im not sure how to re-cast the 'save' variable into what the compiler suggests.. any ideas on how to solve this?