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

  • Home
  • SEARCH
  • 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 8777319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:15:06+00:00 2026-06-13T19:15:06+00:00

I have this code: int board[3][3]; // I am ommiting initialization code for board

  • 0

I have this code:

int board[3][3];        // I am ommiting initialization code for board here so as not to clutter it.
typedef std::vector<std::pair<int [3][3], int> > History;
History hist = History();
const std::pair<int[3][3], int> p = std::make_pair(board, cell);
hist.push_back(p);

but compiling it with g++ gives me this error which I can’t understand:

In file included from /usr/include/c++/4.7/bits/stl_algobase.h:65:0,
                 from /usr/include/c++/4.7/vector:61,
                 from performancesystem.h:29:
/usr/include/c++/4.7/bits/stl_pair.h: In instantiation of
    ‘std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = 
    int (*)[3]; _U2 = int; _T1 = int [3][3]; _T2 = int]’:
Test.cpp:74:65:   required from here
/usr/include/c++/4.7/bits/stl_pair.h:111:39: error: incompatible types in
    assignment of ‘int (* const)[3]’ to ‘int [3][3]’

I always had this problem understanding the difference between pointers and arrays in C++. Shouldn’t they be the same thing? Can anyone help me please?

  • 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-13T19:15:07+00:00Added an answer on June 13, 2026 at 7:15 pm

    Can’t blame you, as the difference of array vs. pointer realizes typically only in dynamically sized structures.

    The array int a[3][4][5][6] e.g. is allocated linearly from memory. It contains 3*4*5*6 units and where a[2][3][4][0] … a[2][3][4][5] are in 6 consecutive indices and where a[0][1][n][5] are each 6 elements apart and where a[1][n][3][6] are each 5*6 elements apart and so on.

    Pointers however provide ‘indirection’.
    The multidimensional array can be implemented by first_level array a[3] providing 3 pointers (indirections) to next level arrays b[4], c[4] and d[4], each of which provide indirection to next level and so on.

    In many real life application (e.g. a table of pointer to strings) one really can’t see the difference, as the syntax hides the details:

    int main(int ac, char **av) { // one can get third character of third string with av[2][2], even though the prototype can be represented with int main(int ac, char *av[]);, but not with int main(int ac, char av[][]); as the dimension of the table av can’t possibly be determined from that syntax.

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

Sidebar

Related Questions

I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p
Ok I currently have this code public int i = 0; //this is outside
I have this code: class MyObj { int Id; string Name; string Location; }
For Andriod I have this code: public Tank(int color) { bounds = new RectF();
I have this simple piece of code : int a = 1, b =
I have this code: //choosed a picture public void onActivityResult(int requestCode, int resultCode, Intent
I have this code: pid_t vPid=fork(); int vStat; switch(vPid){ case -1: perror(fork); exit(1); case
Hello I have this code class Triplets { public: int nVal1; int nVal2; NodeT
I have this code inside a header (edited): template <int i> class A {};
This is my code: public Move makeMove(int[][] board) (... more code ...) int[][] nextMove

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.