- Joined
- May 6, 2007
- Messages
- 1
- Reaction score
- 0
i have this code:
template<class elemType>
class graphType
{
public:
graphType(void){};
~graphType(void){clearGraph();}
void insertPath(elemType & rec, int weight);
void insertVertex(elemType & rec);
bool isEmpty(void) const;
void createGraph(void);
void depthFirstTraversal(void);
void dftAtVertex(elemType vertex);
void breadthFirstTraversal(void);
protected:
template <class elemType>
class graphNode
{
public:
graphNode(elemType &rec): info(rec){};
elemType getInfo(void){return info;}
void setInfo(elemType& nfo){info = nfo;}
protected:
struct adjNode
{
protected:
vector::iterator cityIterator;
int weight;
bool operator == (const adjNode& right){return weight == right.weight;}
bool operator != (const adjNode& right){return weight != right.weight;}
bool operator > (const adjNode& right){return weight > right.weight;}
bool operator >= (const adjNode& right){return weight >= right.weight;}
bool operator < (const adjNode& right){return weight < right.weight;}
bool operator <= (const adjNode& right){return weight <= right.weight;}
};
orderedLinkedListType<adjNode> adjacentNodes;
elemType info;
};
vector<graphNode<elemType> > graph;
void dft(elemType v, bool visited[]);
void clearGraph(void);
};
the struct iterator is going to point to nodes in the main classes' vector so i don't need extra copies of the template data.
i am getting the following errors:
/***********
graphtype.h(56) : error C2955: 'std::vector' : use of class template requires template argument list
graphtype.h(56) : error C2955: 'std::vector' : use of class template requires template argument list
graphtype.h(56) : fatal error C1903: unable to recover from previous error(s); stopping compilation
**********/
if i change it to vector<elemType>::iterator it gives me:
/*******************
graphtype.h(56) : warning C4346: 'std::vector<elemType>::iterator' : dependent name is not a type
graphtype.h(56) :error C2146: syntax error : missing ';' before identifier 'cityIterator'
graphtype.h(56) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
***********************/
i am so confused....
template<class elemType>
class graphType
{
public:
graphType(void){};
~graphType(void){clearGraph();}
void insertPath(elemType & rec, int weight);
void insertVertex(elemType & rec);
bool isEmpty(void) const;
void createGraph(void);
void depthFirstTraversal(void);
void dftAtVertex(elemType vertex);
void breadthFirstTraversal(void);
protected:
template <class elemType>
class graphNode
{
public:
graphNode(elemType &rec): info(rec){};
elemType getInfo(void){return info;}
void setInfo(elemType& nfo){info = nfo;}
protected:
struct adjNode
{
protected:
vector::iterator cityIterator;
int weight;
bool operator == (const adjNode& right){return weight == right.weight;}
bool operator != (const adjNode& right){return weight != right.weight;}
bool operator > (const adjNode& right){return weight > right.weight;}
bool operator >= (const adjNode& right){return weight >= right.weight;}
bool operator < (const adjNode& right){return weight < right.weight;}
bool operator <= (const adjNode& right){return weight <= right.weight;}
};
orderedLinkedListType<adjNode> adjacentNodes;
elemType info;
};
vector<graphNode<elemType> > graph;
void dft(elemType v, bool visited[]);
void clearGraph(void);
};
the struct iterator is going to point to nodes in the main classes' vector so i don't need extra copies of the template data.
i am getting the following errors:
/***********
graphtype.h(56) : error C2955: 'std::vector' : use of class template requires template argument list
graphtype.h(56) : error C2955: 'std::vector' : use of class template requires template argument list
graphtype.h(56) : fatal error C1903: unable to recover from previous error(s); stopping compilation
**********/
if i change it to vector<elemType>::iterator it gives me:
/*******************
graphtype.h(56) : warning C4346: 'std::vector<elemType>::iterator' : dependent name is not a type
graphtype.h(56) :error C2146: syntax error : missing ';' before identifier 'cityIterator'
graphtype.h(56) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
***********************/
i am so confused....