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 8241661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:54:21+00:00 2026-06-07T20:54:21+00:00

Before writing a function that takes a generic bidirectional iterator I wanted to test

  • 0

Before writing a function that takes a generic bidirectional iterator I wanted to test out how it works for a vector of ints.

vector<int> a(10,1);
iterator<bidirectional_iterator_tag, int> i = a.begin();
for (; i != a.end(); ++i) cout << *i;

This code soes not compile. g++ complains you cannot convert the return type of begin() to iterator<bidirectional_iterator_tag, int> and that the operators ++ and * are not defined on it. Obviously I am doing something wrong, would appreciate help.

  • 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-07T20:54:24+00:00Added an answer on June 7, 2026 at 8:54 pm

    Although std::iterator is a base class which eases implementation of new iterators, not all iterators are implemented using this, and not all iterators convert to this. The only requirement for an iterator class is that it provides a given set of operations. No class hierarchy is implied by this, and most containers ship their own iterator classes. So in this case, you should use vector<int>::iterator as the type of your iterator. Or, if you are using the recent C++11 standard, you may use auto to let the compiler infer the type.

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

Sidebar

Related Questions

I'm writing a function in C that takes in a linked list and a
I'm writing unit tests for a function that takes both an *args and a
I'm writing a function in C that takes a variable number of arguments. size_t
Let's say I'm writing my own function that takes in a CFDataRef object, does
I'm writing a shell script that before running needs to check that system Perl
I'm writing code in which I use SQL to test several different conditions before
I'm writing a very simple CRUD app that takes user stories and stores them
I've got a function that takes data and either returns the same data or
I'm writing a Win32 DLL with a function that adds a directory to the
I'm writing a PHP function that will delete all the files in the directory

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.