I want to implement a generic graph data structure in C++. I did this before in Java however, there seem to be major differences between Java generics and C++ templates. What I need is an equivalent to the nested generics in Java. Here's an example of the Java code (V means the vertex object, E means the edge object):
1 2 3
public abstract class Vertex<V, E> {
public ArrayList<Edge<V,E>> outgoingEdges();
}
What I came up with for C++ is the following:
1 2 3 4 5 6
template<class V, class E>
class Vertex
{
public:
std::list<Edge<V, E>> outgoingEdges();
};
However, as you probably figured that doesn't work. It gives me the following error:
error: '>>' should be '> >' within a nested template argument list".
How do I do this nested stuff in C++? I'd be so glad for any help!!!
Best,
Henning