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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:49:27+00:00 2026-06-04T19:49:27+00:00

I have a vector and I am adding elements using push_back. When I am

  • 0

I have a vector and I am adding elements using push_back.

When I am debugging I have added one element to the vector, but the vector contains elements for [0] and [1]. The [1] is the element which I pushed on, but [0] looks like some sort of nullable object.

The vector size is 2 also- even though I have only inserted once.

Later in my code I will traverse the vector using vector_name[i]. Initially I would start with i=0, does this mean with a vector you should use 1 (or some sort of iterator)?

  • 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-04T19:49:29+00:00Added an answer on June 4, 2026 at 7:49 pm

    The first element should be vector[0].

    For example:

    int anumber = 300;
    std::vector<int> intvector;
    intvector.push_back(anumber);
    
    std::cout << intvector[0];
    

    Will print 300.

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

Sidebar

Related Questions

I have the following function (which worked in Visual Studio): bool Plane::contains(Vector& point){ return
I have a plug-in vector established using System.AddIn that accepts the body of a
I have a vector of booleans. I need to set its elements from n-th
I have a vector containing integer values, which I wish to sum. However, it's
I have writen this program: #include <sstream> #include <math.h> #include <string> #include <vector> using
I have a Collection as Vector<HashMap<String, String>> Actually I am using this as list
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named
I have a vector of beans that holds information I want to display in
I have a vector of pointers to a class. I need to call their
I have a vector containing the values 0, 1, 2 and 3. What I

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.