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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:52:35+00:00 2026-06-10T18:52:35+00:00

Can anybody tell me what is the difference between void fun(MyClass &mc); and void

  • 0

Can anybody tell me what is the difference between

void fun(MyClass &mc);

and

void fun(MyClass& mc);

in C++?

  • 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-10T18:52:36+00:00Added an answer on June 10, 2026 at 6:52 pm

    As given none.

    Originally, C would allow:

    int x, *y;
    

    To declare both an int, x and a pointer to int, y.

    Hence part of the definition of the type – the bit that makes it a pointer – could be separated from another part.

    C++ copied this wholesale.

    Then references where added, and they got a similar style of declaration except with & rather than *. This meant that both MyClass &mc and MyClass& mc were allowed.

    On the choice when it comes to *, Strousup wrote:

    Both are “right” in the sense that
    both are valid C and C++ and both have
    exactly the same meaning. As far as
    the language definitions and the
    compilers are concerned we could just
    as well say “int*p;” or “int * p;”

    The choice between “int* p;” and “int
    *p;” is not about right and wrong, but about style and emphasis. C emphasized
    expressions; declarations were often
    considered little more than a
    necessary evil. C++, on the other
    hand, has a heavy emphasis on types.

    A “typical C programmer” writes “int
    *p;” and explains it “*p is what is the int” emphasizing syntax, and may
    point to the C (and C++) declaration
    grammar to argue for the correctness
    of the style. Indeed, the * binds to
    the name p in the grammar.

    A “typical C++ programmer” writes
    “int* p;” and explains it “p is a
    pointer to an int” emphasizing type.
    Indeed the type of p is int*. I
    clearly prefer that emphasis and see
    it as important for using the more
    advanced parts of C++ well.

    The critical confusion comes (only)
    when people try to declare several
    pointers with a single declaration:

    int* p, p1; // probable error: p1 is
    not an int*

    Placing the * closer to the name does
    not make this kind of error
    significantly less likely.

    int *p, p1; // probable error?

    Declaring one name per declaration
    minimizes the problem – in particular
    when we initialize the variables.
    People are far less likely to write:

    int* p = &i; int p1 = p; // error:
    int initialized by int*

    And if they do, the compiler will
    complain.

    Whenever something can be done in two
    ways, someone will be confused.
    Whenever something is a matter of
    taste, discussions can drag on
    forever. Stick to one pointer per
    declaration and always initialize
    variables and the source of confusion
    disappears. See The Design and
    Evolution of C++ for a longer
    discussion of the C declaration
    syntax.

    By extension, when it comes to &, MyClass& mc matches the “typical C++” style.

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

Sidebar

Related Questions

Can anybody tell me what is the difference between standard iOS account and enterprise
Can anybody tell me the difference between a INET Socket and any other socket?
Can anybody tell me the difference between far pointers and near pointers in C?
Can anybody please tell me the exact difference between these two syntax , I
Can anybody tell me the effective difference between the following connection strings: <add key=ConnectionString
Can anybody please tell me what is the exact difference between stretching and scaling
Can anybody tell me the difference between these two JavaScript commands? Also what is
Can anybody tell me the difference between these two ways of formatting numbers using
Can anybody tell me what is the difference between SENSOR_DELAY_NORMAL , SENSOR_DELAY_GAME , SENSOR_DELAY_UI
can anybody tell me the difference of using '===' as if (null === $this->getName())

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.