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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:54:05+00:00 2026-06-17T20:54:05+00:00

Possible Duplicate: C++: How do I decide if to pass params by ref or

  • 0

Possible Duplicate:
C++: How do I decide if to pass params by ref or by value?

The following function has been written from C++ Primer, 5th Edition Page 211 and Page 214. This function will return the position of the first occurrence of a given character in a string and tell the number of occurrences of that character in that string.

string::size_type find_char(const string &s, char c, string::size_type &occurs)
{
      // Compares the given character with string 
      // Records the first occurrence of that character
      // The change in &occurs is reflected back to the original variable
}

The authors recommend the use of ‘References to Avoid Copies’ when passing parameters and the use of ‘const reference parameters’ for parameters that the function doesn’t change. Why didn’t they make char c a const reference parameter?

  • 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-17T20:54:06+00:00Added an answer on June 17, 2026 at 8:54 pm

    Why didn’t they make char c a const reference parameter?

    char is so small, it’s generally cheaper to pass it by value rather than by reference (const or otherwise).

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

Sidebar

Related Questions

Possible Duplicate: How do I tell if a variable has a numeric value in
Possible Duplicate: Interesting test of Javascript RegExp Regular expression test can't decide between true
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Who actually last decide what is the Generic Type? As my question
Possible Duplicate: android.os.NetworkOnMainThreadException I decide to use google api client . I get a
Possible Duplicate: How iPhone 5 + iOS6 will decide if an app must be
Possible Duplicate: how to decode this JSON string? When fetching data from another site
Possible Duplicate: Coding to interfaces? I am reading the Collections tutorial from Java and
Possible Duplicate: ‘ascii’ codec can’t decode byte (problem when using django) From a Chrome
Possible Duplicate: What's the best way to pass a PHP variable to Javascript? I

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.