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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:11:08+00:00 2026-06-15T23:11:08+00:00

OK, I know that in C++ a – let’s say 2-dimensional – array can

  • 0

OK, I know that in C++ a – let’s say 2-dimensional – array can be initialized this way :

int theArray[5][3] = { 
    {1,2,3},
    {4,5,6},
    {7,8,9},
    {10,11,12},
    {13,14,15} 
};

Now, what if I want to use pre-existing arrays as theArray‘s elements?

E.g.

// A, B, C, D,... have already been declared as :
// `const U64 A[] = { 1,2,3,4 };` etc...

const U64 multiDimArray[12][64] = { 
     A, B, C, D, E, F,  
     G, H, I, J, K, L
};

This one, throws an error though :

cannot initialize an array element of type 'const U64' 
(aka 'const unsigned long long') with an lvalue of type 'const U64 [64]'

I see the point, but hopefully you can see mine.

Is there a workaround so that I can easily achieve the same thing? (Any suggestion – perhaps something using Boost? – is welcome)

  • 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-15T23:11:09+00:00Added an answer on June 15, 2026 at 11:11 pm

    I can see why this is useful, however, in C, using just the variable name of an array will return the address of the array in memory. The compiler has no idea as to what is actually stored at A during compile time, so this wouldn’t work.

    As an alternative, what you could do is either use a memcpy and copy the elements into the array (but then it won’t be const), or you could use a #define A { 1, 2, 3, 4 } and then maybe do something like:

    #define A_val { 1, 2, 3, 4 }
    #define B_val { 5, 6, 7, 8 }
    const U64 multiDimArray[12][64] = {
        A_val,
        B_val,
        // and so on and so forth
    }
    const U64 A[4] = A_val; // if you need this
    const U64 B[4] = B_val; // you can do it like this
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that you can cache the WSDL but is there a way to
I know that Javascript is asynchronous, but in this case I can't see why
I know that if a parameter looks like this: @RequestParam(userId) String userId I can
I know that this sort of question has been asked here before, but still
I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
I know that I can hijack a form by showing a login form in
I know that I can use virtual keyword to tell the entity framework that
I know that you can set the number of threads to use for all
I know that I can get access to column properties via: select * from
I know that .Net framework runtime is contained in mscoree.dll.Can anyone help me in

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.