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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:37:40+00:00 2026-05-15T08:37:40+00:00

I understand passing a pointer, and returning a pointer: char * strcat ( char

  • 0

I understand passing a pointer, and returning a pointer:

char * strcat ( char * destination, const char * source );

You’re passing a variable that contains the address to a char; returning the same.

But what does it mean to pass something using the reference operator? Or to return it?

string& insert ( size_t pos1, const string& str );

I mean, I understand what actually happens, I just don’t understand the notation. Why isn’t the notation this instead:

string * insert ( size_t pos1, const string * str ); //made up

I presume it has something to do with passing/returning the instance of a class, but what? Is this syntax valid; if not why not and if so what does it mean?

char & strcat ( char & destination, const char & source ); //made up

(all of the function declarations, except the last made-up two, are from http://www.cplusplus.com )

  • 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-15T08:37:42+00:00Added an answer on May 15, 2026 at 8:37 am

    Simply said, a reference is a pointer without telling you it’s a pointer.

    If you would write the following in plain C:

    void getpi (float *f)
    {
    *f = 3.14;
    }
    
    float v;
    getpi(&v);
    

    You can write the following in C++ using references:

    void getpi (float &f)
    {
    f = 3.14;
    }
    
    float v;
    getpi(v);
    

    It has the additional advantage that you can move from normal by-value argument to by-reference argument, without making changes to the caller. Suppose you have this:

    class X;   // A rather small class that can be easily copied
    void doSomething (X x);
    

    But after a while, class X becomes really big and you don’t want to pass it by value anymore.
    In plain C you have to change the argument to a pointer argument, and change all the callers.
    In C++ you can simply do this:

    void doSomething (X &x);
    

    And you don’t have to change any of the callers.

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

Sidebar

Related Questions

I don't understand why passing a pointer to a function doesn't change the data
I understand when passing a function pointer to an event handler you cannot invoke
I am currently learning bash programming and dont really understand why the passing argument
I understand this is not according to standard, however a partner is passing XML
My form is passing dates in the format 2 Apr 2012 I understand I
I understand that: '\n' // literally the backslash character followed by the character for
I understand, from MSDN, that ClassInitialize is to mark a method that will do
I understand this is an easy question but for some reason this just isn't
I understand what weak tables are. But I'd like to know where weak tables
I'm passing an object from activity to another. Then from that activity to another

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.