Possible Duplicate:
Why should the implementation and the declaration of a template class be in the same header file?
was hoping you could help me out.
I know this question (after doing a google search) has been asked millions of times. I'm sure the solution to my problem is in one of those millions of asked questions, but I couldnt find it so I decided to ask.
I am getting this error specifically:
Error 1 error C2512: 'NodeQueue' : no appropriate default constructor available a:\work\fast\semi 5\automata\assignments\progass1\progass1\progass1\tree.h 33 1 progass1
the specific line has this defination:
level=new NodeQueue<Node>;
getting the same error for the next line as well but the cause is the same..
I've got default contructors for everything not sure why this is happening.. Here are parts of the code:
the top part of the header file:
#include <iostream>
using namespace std;
#include "intarr.h"
class Node;
template <typename t>
class QueueNode;
template <typename t>
class NodeQueue;
Tree:
class Tree{
Node* root;
int level_length;
Node* curr;
NodeQueue <Node>* level,*level_bak;
public:
Tree(){
root=NULL;
level_length=0;
curr=NULL;
level=new NodeQueue<Node>;
level_bak=new NodeQueue<Node>;
}
// I doubt you need the rest...
class node
class Node{
public:
Node *top,*right,*bottom,*left,*prev;
Node *a,*b,*c;
int row,col;
Node(){
}
Node(int x,int y){
top=right=bottom=left=prev=NULL;
row=x;col=y;
a=b=c=NULL;
}
};
queuenode (i.e queue's node)
template <typename t>
class QueueNode {
public:
QueueNode* next;
QueueNode* prev;
t *value;
QueueNode(){
}
QueueNode(t* value){
next=NULL;
this->value=value;
}
};
nodequeue:
template <typename t>
class NodeQueue {
QueueNode *head;
QueueNode *tail;
//lhs=bottom;
public:
NodeQueue(){
head=NULL;
tail=NULL;
}
//....... rest of the code you dont need