Определение ниже не соответствует ... Я думаю, что это как-то связано со специализацией шаблона класса (Vector) в другом шаблоне класса (Graph).Спасибо!
this is the part giving me trouble (defined in Graph below) ->
std::map<KeyType, Vertex<KeyType, ObjectType> > vertexes;
template <class KeyType, class ObjectType>
class Vertex
{
private:
KeyType key;
const ObjectType* object;
public:
Vertex(const KeyType& key, const ObjectType& object);
const KeyType getKey();
};
template <class KeyType, class ObjectType>
class Graph
{
private:
std::map<KeyType, Vertex<KeyType, ObjectType> > vertexes;
public:
const Vertex<KeyType, ObjectType>& createVertex(const KeyType& key, const ObjectType& object);
};
template <class KeyType, class ObjectType>
const Vertex<KeyType, ObjectType>& Graph<KeyType, ObjectType>::createVertex(const KeyType& key, const ObjectType& object)
{
Vertex<KeyType, ObjectType> *vertex = new Vertex<KeyType, ObjectType>(key, object);
vertexes.insert(pair<KeyType, Vertex<KeyType, ObjectType> >(vertex.getKey(), vertex));
return *vertex;
};
Отчеты Visual Studio 10:
Ошибка 1, ошибка C2228: слева от '.getKey' должен быть класс / struct / union c: \ Documents \ visual studio 2010 \ projects\ socialnetwork \ socialnetwork \ graph.h 46 1 SocialNetwork
Строка, упомянутая в ошибке, соответствует вызову vertexes.insert в конце.
ОБНОВЛЕНИЕ: внесено исправление, предложенное двумя авторамиизменить >> на>>.Нет разницы.Ошибка сохраняется.