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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:42:06+00:00 2026-06-09T07:42:06+00:00

I wonder if the following construction is possible: typedef std::bitset<4> BIT4; BIT4* x=new BIT4[3];

  • 0

I wonder if the following construction is possible:

typedef std::bitset<4> BIT4;
BIT4* x=new BIT4[3];
BIT4* y=new BIT4[5];

My concerns are:

(1) is the array of BIT4 a legal construction?

(2) if yes, how the pointer will address these arrays of size 3 and 5? last element of these arrays seems to take 1/2 byte, is another half just lost and we start the next array from a new byte or how does it work?

Thank you for your help!

  • 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-09T07:42:09+00:00Added an answer on June 9, 2026 at 7:42 am

    What you are trying to do as I understand is

    use 12 bits for 3 elements in an array called x

    use 20 bits for 5 elements in an array called y

    This is wrong as you will end up using:

    • 3 bytes for x
    • 5 bytes for y

    if you want to achieve what you want you need to do it like this:

    std::bitset<4*3> x;   // this will occupy 12 + 4 Padding Bits = 2 bytes
    std::bitset<4*5> y;   // this will occupy 20 + 4 Padding Bits = 3 bytes
    

    and you can of course allocate it dynamically if you want to.

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

Sidebar

Related Questions

I wonder why the following does not work with Visual studio typedef struct {
I wonder if the following is possible: I have a dll that I have
I wonder if the following is possible. A user logs in on my website,
I'm new to Moq and I wonder how I could write the following test
I wonder if it is possible to create an editbox similar to the following
I wonder if the two following implementations will produce exactly the same thing with
I wonder if it is possible to catch exceptions in the following case: The
I wonder why in the following code, d is not being cons ed into
wonder whether someone can help me with the following one... I have a struct
I wonder which method among the following three methods is the best to perform

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.