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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:02:09+00:00 2026-05-14T07:02:09+00:00

Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new

  • 0

Having code:

int** a = new int*[2];
a[0] = new int(1);
a[1] = new int(2);
cout << "a[0] " << a[0] << '\n';
cout << "a[1] " << a[1] << '\n';
cout << "a[2] " << a[2] << '\n';
cout << "a[0] + 1 " << a[0] + 1 << '\n';//WHY THIS ISN'T == a[1] ?
cout << "*(a + 1): " << *(a + 1) << '\n'; //WHY THIS IS == a[1] ?
cout << "a[0] - a[1] " << static_cast<int>(a[0] - a[1])<< '\n';//WHY THIS IS == 16 not 4?

cout << sizeof(int**);

Questions are included right next to relevant lines in code.

  • 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-05-14T07:02:09+00:00Added an answer on May 14, 2026 at 7:02 am

    a[0] + 1 means that 1 is added to the value stored in a[0]

    *(a + 1) means that 1 * sizeof(int) is added to the memory address of a, and then the value at that location is accessed, meaning you get a[1]

    Read more about pointers here.

    As for your last question, there is no guarantee it will print any specific value, since the two memory addresses do not have to be contiguous. For me it prints -4 for example.

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

Sidebar

Related Questions

Having this code... var b = new ReadOnlyCollection<int>(new[] { 2, 4, 2, 2 });
Having code: struct B { int* a; B(int value):a(new int(value)) { } B():a(nullptr){} B(const
Having this code: using (BinaryWriter writer = new BinaryWriter(File.Open(ProjectPath, FileMode.Create))) { //save something here
I having below code for different artifacts, Entity public class ChooseFirst { public int
I am having some trouble getting this simple code to work: #pragma once #include
I have the following C++ code: typedef int* IntPtr; const int* cip = new
Here is my new edited code I am having trouble with my final if
Im having a problem with my code atm and Im not sure what the
Im having trouble accessing the following vector. Im new to vectors so this is
Having code: Date::Date(const char* day, const char* month, const char* year):is_leap__(false) { my_day_ =

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.