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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:59:18+00:00 2026-06-15T03:59:18+00:00

I have the vector: vector<int[2]> storeInventory; //storeInventory[INDEX#]{ITEMNUM, QUANTITY} and I am wanting to use

  • 0

I have the vector:

vector<int[2]> storeInventory; //storeInventory[INDEX#]{ITEMNUM, QUANTITY}

and I am wanting to use the push_back() method to add new arrays to the inventory vector. Something similar to this:

const int ORANGE = 100001;
const int GRAPE = 100002

storeInventory.push_back({GRAPE,24});
storeInventory.push_back{ORANGE, 30};

However, when I try using the syntax as I have above I get the error Error: excpeted an expression. Is what I am trying just not possible, or am I just going about it the wrong way?

  • 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-15T03:59:19+00:00Added an answer on June 15, 2026 at 3:59 am

    Built-in arrays are not Assignable or CopyConstructible. This violates container element requirements (at least for C++03 and earlier). In other words, you can’t have std::vector of int[2] elements. You have to wrap your array type to satisfy the above requirements.

    As it has already been suggested, std::array in a perfect candidate for a wrapper type in C++11. Or you can just do

    struct Int2 {
      int a[2];
    };
    

    and use std::vector<Int2>.

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

Sidebar

Related Questions

Lets we have std::vector <std::vector <int>> myVec; myVec.resize(100); myVec[0].push_back(1); myVec[0].push_back(2); When I break the
I have a vector declared as std::vector<int> MyVector; MyVector.push_back(5); MyVector.push_back(6); MyVector.push_back(7); How do should
I have declared: vector<int> * part = new vector<int>[indmap]; Ok, I know it: why
I have vector< pair<int, int>> myVec (N); I want to have all pairs initialized
Suppose I have a vector<int> myvec and I want to loop through all of
I have a vector of vectors: vector< vector<int> > BigVec; It contains an arbitrary
I have a std::vector<int> , and I want to delete the n th element.
I have a function that creates a 2D vector void generate(int n) { vector<
I have some numbers stored in a std::vector<int> . I want to find which
I have a map<int int> . I need to get a vector of the

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.