Tengo la plantilla Vertex en vertex.h. Desde mi graph.h:¿Qué hace que este "declarador no sea válido"? C++
20 template<class edgeDecor, class vertexDecor, bool dir>
21 class Vertex;
que utilizo en mi plantilla de gráfico.
Utilicé la plantilla Vertex con éxito en todo mi gráfico, devuelvo punteros a Vértices, etc. Ahora, por primera vez, intento declarar y crear instancias de un objeto Vertex, y gcc me dice que mi 'declarante' es 'inválido'. ¿Cómo puede ser esto?
81 template<class edgeDecor, class vertexDecor, bool dir>
82 Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool print = false) const
83 {
84 /* Construct new Graph with apropriate decorators */
85 Graph<edgeDecor,int,dir> span = new Graph<edgeDecor,int,dir>();
86 span.E.reserve(this->E.size());
87
88 typename Vertex<edgeDecor,int,dir> v = new Vertex(INT_MAX);
89 span.V = new vector<Vertex<edgeDecor,int,dir> >(this->V.size,v);
90 };
y GCC está diciendo:
graph.h: In member function ‘Graph<edgeDecor, int, dir> Graph<edgeDecor, vertexDecor, dir>::Dijkstra(Vertex<edgeDecor, vertexDecor, dir>, bool) const’:
graph.h:88: error: invalid declarator before ‘v’
graph.h:89: error: ‘v’ was not declared in this scope
Sé que esto es probablemente otra pregunta noob, pero podrá apreciar ninguna ayuda.
Probablemente no está relacionado con este problema, pero ¿está seguro de que quiere que "= new Vertex (INT_MAX)"? ¿Quizás quiso decir "vertex" sin capitalizar (que supongo que es un typedef)? También Vertex <...> realmente tiene un ctor tomando un puntero vértice/vértice? –