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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:39:56+00:00 2026-06-09T13:39:56+00:00

I’m having a problem with the new ranged based for statement: for ( InputReaderObject

  • 0

I’m having a problem with the new ranged based for statement:

for ( InputReaderObject irb : InputReader )
{
 ......
}

So as you can see, i have a class called InputReaderObject, and then another variable that is defined as an extern in a included header file. And is declared long before used here as an InputReaderObject. Now, to the actual problem, both my intellisence and my compiler is strangling me

no callable ‘begin’ function found for type ‘InputReaderObject *’.

Now my suspicous is that in the included header file, it is declared as an extern, and isn’t really visible as an array of InputReaderObject(it is declared as an array).

So, does ranged based for statements work with pointers? Or is this my problem?

Thank You

  • 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-09T13:39:58+00:00Added an answer on June 9, 2026 at 1:39 pm

    If InputReader is declared in the header file as an array of constant size, then it should work as long as you #include <array> or #include <iterator> or any of several other library headers, so that you get the declarations

    template<typename T, std::size_t N> T* std::begin(T (&array)[N]);
    template<typename T, std::size_t N> T* std::end(T (&array)[N]);
    

    But what if InputReader is declared something like

    extern InputReaderObject* InputReader;
    

    or maybe

    extern InputReaderObject InputReader[];
    

    …? It’s not obvious from that how many objects are in the array, but let’s suppose the same header also has something like:

    extern unsigned int InputReaderSize;
    

    Anything you pass into the range-based for loop needs to have begin and end functions which return iterators. (The functions can be class members, found by argument-dependent lookup, or in namespace std.) The standard library defines some begin and end functions for actual arrays and standard containers, but you can extend it by defining your own:

    #include <iterator>
    
    struct InputReaderLoopType {
        InputReaderObject* begin() const { return InputReader; }
        InputReaderObject* end() const { return InputReader + InputReaderSize; }
    };
    extern const InputReaderLoopType InputReaderLoop;
    

    would let you do…

    for ( InputReaderObject& irb : InputReaderLoop )
    

    (Making irb a reference instead of a copy is just a suggestion. You might actually need a copy for some reason.)

    You could also define InputReaderObject* begin(InputReaderObject*); and InputReaderObject* end(InputReaderObject*); if you really want the loop to work with InputReader as already declared. But that could cause confusing results if somebody had a pointer of that type which is not in fact InputReader.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

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.