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

  • SEARCH
  • Home
  • 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 8857505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:36:20+00:00 2026-06-14T14:36:20+00:00

I have a vector players which I would like to iterate over. The ‘player’

  • 0

I have a vector players which I would like to iterate over. The ‘player’ struct appears as follows:

struct player {
string name;
int rating;
};

I am using the iterator in a for loop to see if any of the ‘players’ have the name ‘playerName’ (a string).

for (vector<player>::iterator itr = players.begin(); itr != players.end(); ++itr) {
if (playerName.compare(*itr->name) == 0) return true;
}
return false;

Unfortunately, I keep running into an error: ‘error C2100: illegal indirection’ (visual C++ 2008). I believe that I’m dereferencing the iterator incorrectly; is there a better way to do so?

  • 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-06-14T14:36:21+00:00Added an answer on June 14, 2026 at 2:36 pm

    *itr->name is equivalent to (*itr)->name.

    In your code, the type of (*itr) is player, not player*, so the compiler is basically telling you that you’re trying to dereference something that isn’t a pointer.

    The correct way of doing that would be (*itr).name or itr->name, both meaning “dereference itr then access name”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector of pairs representing hops between nodes which I would like
I have a vector called players and a class called Player. And what I'm
I have the following vector to store elements of type player: std::vector<player> players; in
I have a vector of strings which are changing its contents for no apparent
I have one vector instance and I'm exporting swf with Flash Player 10/10.1. I
I have an Entity baseclass which the classes Player and Enemy Inherit. class Entity
I have an Entity baseclass which the classes Player and Enemy Inherit. Both player
I have two vectors in a game. One vector is the player, one vector
I have vector< pair<int, int>> myVec (N); I want to have all pairs initialized
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named

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.