I'm having some trouble with a generic class I'm trying to create. I'd like to use this class to perform DFS searches on different variations of a base graph class, but the compiler doesn't agree with me. The errors I'm getting are: unknown type "NodeType", and unknown type "EdgeType". (Which I think is funny because intellisense pickups up the definition just fine and shows me a tool tip with the class definition of the SparseGraph class including the where clause. So I know it KNOWS the definition I'm trying to use... but I digress)
So to be clear the "SearchGraphDFS" class is the problem. The compiler (VS2008) errors on NodeType and EdgeType. The other 3 class definitions are included for clarity.Code:class SearchGraphDFS<GraphType> where GraphType : SparseGraph<NodeType,EdgeType> class SparseGraph<NodeType, EdgeType> where NodeType : GraphNode, new() where EdgeType : GraphEdge, new() class GraphEdge class GraphNode
The question is if my way isn't the correct way to implement what I'm trying to achieve, then what is? Or is there a way I can define NodeType and EdgeType without having to do something like this?
Code:class SearchGraphDFS<GraphType,NodeType,EdgeType> where GraphType : SparseGraph<NodeType,EdgeType>




Reply With Quote