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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:17:09+00:00 2026-06-12T18:17:09+00:00

People tend to say pass by (const) reference if you want speed , to

  • 0

People tend to say pass by (const) reference if you want speed, to be honest I rarely use const reference on methods I create just because of speed, I only make a reference when I need it, for example to give a value to a variable, as in this SSCE

void Do( int& iref )
{
    a = 2;
}

{
    int a = 0;
    Do( a );
}

The question actually is, if the object was created on the function call, if will it also be passed as a reference, how does that works?

void Add( CString& strPath )
{
    g_Path.push_back( strPath );
}

for( std::string line; getline( input, line ); )
{
    Add( CString( line.c_str() ) ); //object created on function call
}
  • 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-12T18:17:10+00:00Added an answer on June 12, 2026 at 6:17 pm

    How does that work? It doesn’t. The code doesn’t compile, since temporary objects cannot bind to non-const lvalue references.

    (Temporary objects can bind to const references, or to rvalue references, though.)

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

Sidebar

Related Questions

Inside the Rails code, people tend to use the Enumerable#inject method to create hashes,
When you say optimization, people tend to think speed. But what about embedded systems
I'm just curious where people tend to use FactoryGirl.build_stubbed and where they use double
In various guides and scripts I come across people tend to use different syntax
Having worked with Django , I've seen that people tend to reccommend the use
While looking at MVC3 examples of models. Most people tend to use model classes
I have read a lot of topic here and people tend to store IP
I'm aware of questions like this , where people tend to discuss the general
People use gdb on and off for debugging, of course there are lots of
People keep telling me instead of writing shift 1 bit to the left, just

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.