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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:57:45+00:00 2026-05-13T20:57:45+00:00

Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading

  • 0

Possible Duplicate:
Difference between pointer variable and reference variable in C++

I am reading about the book "Inside the C++ Object Model" by Stanley Lippman. What puzzles me is the difference between a "reference" of an object and a "pointer" to an object. I know that a reference must be initialized when declared, while a pointer could be left for later initialization. But I want to know the physical implementation difference between them.

Why should there be the "reference" mechanism; isn’t it overlapping the function of a pointer? Under what circumstance should we use reference other than pointer? Many thanks.

10:48 AM 11/20/2021

Reference is from the semantic perspective.

Pointer is from the implementation perspective.

It’s kind of like the relation between what and how.

  • 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-13T20:57:45+00:00Added an answer on May 13, 2026 at 8:57 pm

    Most references are implemented using a pointer variable i.e. a reference usually takes up one word of memory. However, a reference that is used purely locally can – and often is – eliminated by the optimizer. For example:

      struct S { int a, int b[100]; };  
      void do_something(const vector<S>& v)
      {
        for (int i=0; i<v.size(); ++i) {
            int*& p = v[i].b;
              for (int j=0; j<100; ++j) cout <<p[j];
      }
    

    In this case, p needs not be stored in memory (maybe it just exists in a register, maybe it disappears into the instructions).

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

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use any android powered device for development, just… May 16, 2026 at 8:49 am
  • Editorial Team
    Editorial Team added an answer Constant conditionals are often enough simply bugs. Consider this: unsigned… May 16, 2026 at 8:49 am
  • Editorial Team
    Editorial Team added an answer Hook up to the DayRender event protected void SomeCalendar_DayRender(object sender,… May 16, 2026 at 8:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I
Possible Duplicate: Difference between “var” and “object” in C# I would like to know
Possible Duplicate: c#: difference between “System.Object” and “object” Hello, In C# there are Object
Possible Duplicate: what is the difference between (.) dot operator and (->) arrow in
Possible Duplicate: Difference between -%> and %> in rails So for an ERB file,
Possible Duplicate: Difference between -%> and %> in rails I need to know what
Possible Duplicate: Difference between a Structure and a Union in C I see this
Possible Duplicate: Difference between lock(locker) and lock(variable_which_I_am_using) In all of the thread-safe code examples
Possible Duplicate: Difference between declaring variables before or in loop? Is there any (or
Possible Duplicate: Difference Between ViewData and TempData? What is major difference between TempData and

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.