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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:24:46+00:00 2026-06-01T22:24:46+00:00

I have a 2d vector which represents a 2d grid; so grid[0][2] for example.

  • 0

I have a 2d vector which represents a 2d grid; so grid[0][2] for example. I am needing to ‘insert’ -might not be the right word here. a vector at a specific location say grid[3][2] there will definitely be a grid[0][0] but when im needing to insert into grid[3][2] there may be nothing before it other than grid[0][0] and there needs to be the space in between for later on. Is there any way to do this?

Thank you for your help.

ps: I should note that the size of the vectors are not known (they will grow over time)

  • 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-01T22:24:47+00:00Added an answer on June 1, 2026 at 10:24 pm

    I’m not sure if I understand your requirements correctly, but:

    std::vector<std::vector<int>> grid(4);  // 4 rows
    
    grid[3].resize(3)  // resize 4th row
    
    grid[3][2] = 42;
    

    Your 2D grid would then “look” like that:

     |
     - 
     |
     -                  <---  3 empty rows
     |
     --------------
     | 0 | 0 | 42 |
     --------------
    

    You can freely resize the rows later on. Note that there is row 0, but no [0][0] element just yet, you have to add it yourself.

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

Sidebar

Related Questions

I have a Vector class which represents a 2D vector. It is templated to
I have a 2-D array in R which represents value data for a grid
Say I have a vector which has thousands of elements. What is the R
So I have a container(any kind, probably std::map or std::vector) which contains objects of
Hey, In C++, I have a vector of type: vector<BaseClass*> myVector; In which, I
I have a numeric vector in R, which consists of both negative and positive
I have a class which has a private attribute vector rectVec; class A {
I have the following function which creates a std::vector of iterators into another container:
I have some numbers stored in a std::vector<int> . I want to find which
I'm wondering something. I have class Polygon , which composes a vector of Line

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.