Frage

return Graph_iterator_Vertex(Vertexs.begin()); 

I do not understand why this line is called the copy constructor, although there is my constructor with a parameter. The arguments constructor parameter written specifically for this design. All that I have found about a similar issue is the use of typename. But it did not solve my problem.

struct Graph_iterator_Vertex
    {
    private:
        typename std::vector<Vertex<Type_Of_Value_Vertex, Type_Of_Value_Edge>>::iterator iterator;

    public:

        Graph_iterator_Vertex(typename std::_Vector_const_iterator<std::vector<Vertex<Type_Of_Value_Vertex, Type_Of_Value_Edge>>> iterator_)

        {
            iterator=iterator_
        }
    };

    const Graph_iterator_Vertex begin(void) const 
    {
        return Graph_iterator_Vertex(Vertexs.begin()); 
    }

where

std::vector<Vertex<Type_Of_Value_Vertex, Type_Of_Value_Edge>> Vertexs;

Error:

error C2440: <function-style-cast>: can not be converted std::_Vector_const_iterator<_Myvec>"in "Graph<Type_Of_Value_Vertex,Type_Of_Value_Edge>::Graph_iterator_Vertex" 
War es hilfreich?

Lösung

you should use

std::vector<Vertex<Type_Of_Value_Vertex, Type_Of_Value_Edge>>::const_iterator

instead of

std::_Vector_const_iterator<std::vector<Vertex<Type_Of_Value_Vertex, Type_Of_Value_Edge>>>

as the type of your function parameter.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top