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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:18:38+00:00 2026-05-16T08:18:38+00:00

const int NUMB = 4; int n[] = {5,6,7,8}; // create a vector of

  • 0
const int NUMB = 4;
int n[] = {5,6,7,8};

// create a vector of strings using the n[] array
vector<int> partnums(n, n + NUMB);

The class functions vector name(src.begin, src.end)

Create a vector initialized with
elements from a source container
beginning at src.begin and ending at
scr.end

According to the book,

The vector partnums is declared as a
vector type int and initialized with
elements from the n array, starting
with the first array element n[0], and
ending with the last array element,
located at position n + NUMB.

I don’t get it, still. “Located at position n+ NUMB, isn’t the index starts at 0?
Or the compiler knows that this src.end is referring to position 1 (scr.begin), and count that from that position in the array n, and count to the 4th position)?

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-05-16T08:18:38+00:00Added an answer on May 16, 2026 at 8:18 am

    The C++ standard library uses a convention that the ‘end’ iterator is actually referring to one element past the end, so in your case ‘begin’ would be the 0th position and ‘end’ the fourth (not third) position.

    What is confusing in your citation above is that n + NUMB is referred to as the last element in the array, which is incorrect. It is the (fictional) element after the last element in the array and simply used as an end marker.

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It depends. Remember, others can access your API too, not… May 16, 2026 at 2:02 pm
  • Editorial Team
    Editorial Team added an answer The detailed answer: Every CSS or JS file referenced in… May 16, 2026 at 2:02 pm
  • Editorial Team
    Editorial Team added an answer I use the Coffee Bytes plugin for code folding, specifically… May 16, 2026 at 2:02 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

const int MIN_NUMBER = 4; class Temp { public: Temp(int x) : X(x) {
1) const int[] array={1,2,3,4}; //this gives below error Error 1 'ConsoleApplication1.Main.array' is of type
I have a private const int defined in a C# class. I want compilation
class A { public: A(const int n_); A(const A& that_); A& operator=(const A& that_);
const int t=5; char buf[t+5]; When I compile this gives error in C but
Consider: int testfunc1 (const int a) { return a; } int testfunc2 (int const
private const int THE_ANSWER = 42; or private const int theAnswer = 42; Personally
void main() { const int * a; *a = 5; } gcc error :
struct A { static const int a = 5; struct B { static const
when doing like this: const int a = 5; I wonder if a will

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.