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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:42:54+00:00 2026-05-17T21:42:54+00:00

How to initialize a 2 dimensional vector<int> in C++? For instance I have 4

  • 0

How to initialize a 2 dimensional vector<int> in C++?

For instance I have 4 arrays each of length 8 ints, like the below

int a1[] = {1,2,3,4,5,6,7,8};
int a2[] = {1,2,3,4,9,10,11,12};
int a3[] = {1,2,5,6,9,10,13,14};
int a4[] = {1,3,5,7,9,11,13,15};

and I have this

vector< vector <int> > aa (4);

aa[i] (a1,a1+8);

But this gives error. I even tried supplying the array a1 to v1 and passed v1 to aa[i] , still it fails.

So what would be the proper way of initializing the elements of a 2 dimensional vector<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-05-17T21:42:55+00:00Added an answer on May 17, 2026 at 9:42 pm
    aa[i].assign(a1,a1+8);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How could I initialize a two dimensional vector in the contstructor of a class
I have a two-dimensional ArrayList to store Block objects to use later. However, it
I have a three dimensional static const array that is acting as a lookup
I have a two-dimensional char array declared with four strings. private static string string1
I'm writing a class for solving sudoku puzzles that has some two dimensional arrays
I'm trying to achieve a dynamic two dimensional array in C. Whenever the program
Excuse the newbie question. I'm trying to create a two dimensional array in ruby,
First the error: error: a value of type float * cannot be used to
I'm an experienced PHP developer transitioning to C#. At present I am working on

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.