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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:30:53+00:00 2026-05-30T03:30:53+00:00

I have declared my two dimensional array like this. But getting an error due

  • 0

I have declared my two dimensional array like this. But getting an error due to that

vector <vector <int> > plain(vector <int>(4,0))  = {{23,43,45,56},
                                                    {67,85,13,59},
                                                    {48,23,9,57},
                                                    {24,52,90,12}};


rijndael.cpp:12:51: error: expected ‘,’ or ‘;’ before ‘=’ token
rijndael.cpp:57:1: error: expected ‘}’ at end of input

All prior semi colons have been properly assigned.
Can you tell me where I’m going wrong in this declaration ?

I removed the constructor call and my declaration now is

vector <vector <int> > plain/*(vector <int>(4,0))*/  = {{23,43,45,56},
                                                        {67,85,13,59},
                                                        {48,23,9,57},
                                                        {24,52,90,12}};

But the error now is

rijndael.cpp:15:19: error: in C++98 ‘plain’ must be initialized by constructor, not by ‘{...}’
rijndael.cpp:15:19: error: deducing from brace-enclosed initializer list requires #include <initializer_list>
rijndael.cpp:15:19: error: deducing from brace-enclosed initializer list requires #include <initializer_list>
rijndael.cpp:15:19: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
rijndael.cpp:15:19: error: could not convert ‘{{23, 43, 45, 56}, {67, 85, 13, 59}, {48, 23, 9, 57}, {24, 52, 90, 12}}’ to ‘std::vector<std::vector<int> >’

How do I rectify this ?
Any help is very much appreciated.

  • 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-30T03:30:55+00:00Added an answer on May 30, 2026 at 3:30 am

    You can’t have both a constructor call and a list initialization, stick to one, e.g.:

    vector<vector<int>> plain{{23,43,45,56},
                                 {67,85,13,59},
                                 {48,23,9,57},
                                 {24,52,90,12}};
    

    (You can omit the = for list initialization.)

    On your edit: Well, the error explains it all, reading it would help. You need C++11 mode for list initialization. If you don’t want that, you’ll have to copy with the ctor to prepare the 2D array and then fill it in after construction.

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

Sidebar

Related Questions

I have two classes declared like this: class Object1 { protected ulong guid; protected
I have a two dimensional array that I need to load data into. I
I have a two-dimensional char array declared with four strings. private static string string1
I have a variable called names which is a two dimensional array. I declared
I have a 49 space one dimensional array declared as int boardArray [49]; and
I have a header file for a game that declares a two-dimensional array for
I am working on a game that will have a two dimensional board of
when declaring the two dimensional array int random[height][width]; and then using it in a
I have two brushes declared in my ResourceDictionary and I would like the user
I have a two dimensional array, i.e. an array of sequences which are also

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.