Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4232740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:07:59+00:00 2026-05-21T02:07:59+00:00

The definition below is failing… I’m thinking it has something to do with specializing

  • 0

The definition below is failing… I’m thinking it has something to do with specializing a class template (Vector) within another class template (Graph). Thanks!

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 reports:

Error 1 error C2228: left of ‘.getKey’ must have class/struct/union c:\documents\visual studio 2010\projects\socialnetwork\socialnetwork\graph.h 46 1 SocialNetwork

The line mentioned in the error corresponds to the the vertexes.insert call near the end.

UPDATE: made correction as suggested by 2 posters of changing the >> to > >. No difference. Error persists.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:08:00+00:00Added an answer on May 21, 2026 at 2:08 am

    Your vertex is a pointer. To access getKey you need to use -> operator, not .. Plus, you can use std::make_pair to avoid repeating the types.

    vertexes.insert(std::make_pair(vertex->getKey(), *vertex));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the class definition below. How would one go about deciding whether the stub
Given this definition: [UniqueId(Ident)] public class MyClass : MyBase { public int Ident{ get;
Let's have the following class definition: CThread::CThread () { this->hThread = NULL; this->hThreadId =
Will adding new member function into d pointer class definition break binary compatibility? For
I'm an intermediate C++ user and I encountered the following situation. The class definition
Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty(FieldId); string fldProValue = (string)ffdPro.GetProperty(FieldValue); FormFieldDef
By definition algorithms are independent from the medium they run on. E.g. I use
I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the
A basic definition and example and a few references for X-Macros is given in
What is the best definition of a thread and what is a process? If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.