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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:23:03+00:00 2026-06-14T13:23:03+00:00

I have a system where I need to get codes for specific positions. There

  • 0

I have a system where I need to get “codes” for specific positions. There is a constant number of positions, 1 to 40, however, each position can have different number of codes (from 2 to 20). The container is constant, it needs to be defined, then is just used to look up positions for the rest of the program.

For example, I need to be able to do something like myCodes.at(position3) and get {1, 3, 9, 23, 52} and myCodes.at(position7) and get {23, 52}

So, the outer container is of constant size, but the inner container can vary in size from 2 to 20. The way I know how to do this is using arrays, and just make the second dimension the max possible size (20): const int myCodes[40][20], then just “pad” the inner array with extra 0’s.

However, this feels really wasteful, especially because many of the inner arrays would only be holding 2 elements. I am also working on learning C++11, so I would prefer a “modern” solution if there is one.

  • 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-14T13:23:04+00:00Added an answer on June 14, 2026 at 1:23 pm

    This is likely what you want:

    std::array<std::vector<code>, const_size>
    

    The outer is constant and the inner is dynamic.

    Having both be constant and using padding will be faster, but much uglier and so don’t try it at first. 18*20 unused ints is not much of a waste on modern hardware.

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

Sidebar

Related Questions

I have a timeclock system where i need to print a report for each
I need suggestion about YAMI library . I have a system which receives Json
I have an HTML help system that I need to convert to SharePoint. The
I am implementing a system where I need real-time updates. I have been looking
I have a form MyForm : System.Windows.Forms.Form {} and I need to call Site.GetService(..)
I need to implement a system where I have 5 forms. An agent then
I have a PMS(Pantone Matching System) color value. I need to find the corresponding
I have a web based (perl/MySQL) CRM system, and I need a section for
I need to archive data from a CRM system. Does anyone have any idea
I have a design question. We need to put some default, system defined content

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.