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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:53:26+00:00 2026-05-26T22:53:26+00:00

In attempt to explain that arrays are just pointers (in C++) to our class,

  • 0

In attempt to explain that arrays are just pointers (in C++) to our class, my professor showed us this:

array[5]      // cout'ing this 
*(array + 5)  // would return the same value as this

I’m having a little trouble completely understanding it. Here’s my thinking:

array is the address of the first location and so if we add 5 to that address, we move 5 addresses in memory. The pointer operator pulls the data from the memory location.

Is this the correct idea? The idea still feels foggy with me and just feel like I don’t understand it completely. I think hearing someone else explain it might help me understand it more. Thanks in advance!

  • 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-26T22:53:27+00:00Added an answer on May 26, 2026 at 10:53 pm

    You’ve got the right idea.

    Arrays implicitly cast to pointers. Interestingly, [] works on pointers, not arrays.

    a[b] Subscript operator is defined as *(a + (b)). [] is used as syntactic sugar – it’s much more pleasant to write array[5] instead of *(array + 5)

    Pointer arithmetic with a pointer and an integer p + i increases the address at p by i * sizeof(*p) bytes.

    char* p; 
    p + 5; // address increased by 5
    
    int* p;
    p + 5; // address increased by 20 as sizeof(*p) is 4
    

    The * operator performs indirection. It will give you what the pointer is pointing to.

    int x[2];
    int* p = &x[0]; // could also be int* p = x;
    *p = 5;         // x[0] is now 5
    *(p + 1) = 10;  // x[1] is now 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An attempt to explain this as best as possible: To begin, I have a
First attempt to use this cool site - after searching for 2 hours: So
I attempt to use webservice return POCO class generated from entity data model as
In an attempt to add some parameter validation and correct usage semantics to our
This is an attempt to rephrase a question I asked earlier. I'd like to
I shall attempt to explain the scenario. I have a gridview I wish to
I will try to explain this the best way I can, but feel free
This is an attempt to rephrase my previous question as a result of the
Sorry in advance im going to try and explain this as best as possible....
I'm not understanding this behavior. Maybe someone can explain to me why my current

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.