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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:27:41+00:00 2026-06-19T00:27:41+00:00

I am trying to initialize a pointer ( *vectorName ) with a 2D vector

  • 0

I am trying to initialize a pointer (*vectorName) with a 2D vector 366 by 4.

Both

vector<int> *vectorName = new vector<int>(366, new vector<int>(4));

and

vector<int> *vectorName = new vector<int>(366, vector<int>(4));

do not work and give me the error

Error: no instance of constructor “std::vector, <_Ty, _Alloc>::vector [with_ty=int, _Alloc=std_allocator]”
argument types are (const int, std::vector>*)

What can I do?

This is happening within the main function.

  • 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-19T00:27:42+00:00Added an answer on June 19, 2026 at 12:27 am
    vector<int> *vectorName = new vector<int>(366, vector<int>(4));
    

    The above doesn’t work because the vector constructor template (ignoring a few things) looks as follows:

    vector <TYPE> (SIZE, variable of type TYPE);
    

    And in vector<int>(366, vector<int>(4)), vector <int> (4) is not of type int.

    To create a vector with 366 elements that are vector of ints of size 4:

    vector<vector<int> > *vectorName = new vector<vector<int> >(366, vector<int>(4));
    

    or, if you don’t need a pointer: (which you quite possibly don’t)

    vector<vector<int> > vectorName(366, vector<int>(4));
    

    As a side note, if it’s a fixed size 2D vector, why are you using vector, and not just an array. This would be much simpler:

    int arr[366][4];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to initialize a vector which has integers 1 to n in
I am trying to initialize NSDictionary but it gives me following error: Program received
I'm trying to initialize a dictionary with string elements as keys and int[] elements
I am stuck trying to figure out how to initialize a pointer to a
I'm getting a subscripting compiler error when trying this: int **arrays; // allocate and
Trying to initialize and set things up for a class as follows: class Accel
I'm trying to initialize a Datatable with a default search value that the user
I'm trying to initialize a usercontrol that contains a gridview as hidden when a
I am trying to initialize my controls in Silverlight. I am looking for something
I'm trying to initialize string with iterators and something like this works: ifstream fin(tmp.txt);

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.