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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:46:21+00:00 2026-06-11T21:46:21+00:00

This states I can construct a vector from an array as follows: // the

  • 0

This states I can construct a vector from an array as follows:

// the iterator constructor can be used to construct from arrays:
int myints[] = {16,2,77,29};
vector<int> myvector (myints, myints + sizeof(myints) / sizeof(int) );

Why is the constructor’s second argument myints + sizeof(myints) / sizeof(int)?

  • 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-11T21:46:22+00:00Added an answer on June 11, 2026 at 9:46 pm

    The expression sizeof(myints) / sizeof(int) gets the number of elements in the myints array.

    myints gets a pointer to the first element of the array.

    So the expression myints + sizeof(myints) / sizeof(int) is a pointer one past the end of the myints array, which is what the two-iterator constructor of std::vector expects. This creates a vector with a copy of all the elements in the original array.

    Bear in mind that pointers are iterators, so the above is equivalent to

    vector<int> myvector (std::begin(myints), std::end(myint));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this article where Ayende states NHibernate can (compared to EF 4): Collection
This article on MSDN states that you can use as many try catch blocks
Using wso2 esb i can construct a complete soap message like this: <enrich> <source
How can I achieve this behaviors onclick with jquery : default state: <a href=something.html>Anchor</a>
This works when I have only one state code as a parameter. How can
Can anyone please tell me how to extract this kind of data : [{number:8457215152,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0},{number:4363685555,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0}]
I wonder why I can't read the JSON Object like this : { 1:{bulan:Januari,tahun:2012,tagihan:205000,status:Lunas},
This link states that all columns that are nullable should be added to the
this document states that, in order to cooperates with codes written in a MRR(manual
In the answer to this question ovanes states: Please be aware that boost::lexical_cast is

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.