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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:54:08+00:00 2026-06-11T07:54:08+00:00

I admit my C++ skills are a bit rusty and I’m diving right into

  • 0

I admit my C++ skills are a bit rusty and I’m diving right into C++11 for a new project I’m about to begin. I’ve just found this confusing behaviour where if I write

void MyClass::update() {
    for(SomeClass &i : _list) {
        i.doStuff();
    }
}

or

void MyClass::update() {
    for(SomeClass i : _list) {
        i.doStuff();
    }
}

it seems to work exactly the same, with _list being a std::list<SomeClass>. So I was wondering what’s the use of the ref here, since I’m clearly missing something. I should mention I’m using Apple LLVM 4.0 that comes with Xcode 4.4.1 (4F1003).

Please, feel free to mock and make fun of me if this is an ourageously silly question, I could really use some good ol’ head slapping 🙂

  • 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-11T07:54:10+00:00Added an answer on June 11, 2026 at 7:54 am

    The reference has nothing to do with the container, but with the element you are taking out of it. In the first case you are accessing the element which is in the list and modifying that, in the second case, you make a copy of the element and then change the copy, which will go out of scope anyway.

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

Sidebar

Related Questions

OK so I admit right off the top that this is a bit screwy
I admit, I'm new at this whole Android stuff. I am trying to make
I admit I'm little bit poor in functions in mathematics. But I'm in real
Background I admit, this question stems from an ultimate lack of deep understanding of
I'll admit the title is a bit confusing but it was hard to come
I'll admit, I am pretty new with ASP .NET programming and I have been
I admit this question is getting to the limits of what I know of
I'll be the first one to admit my SQL skills are lacking. Now... Let's
I admit that I don't follow much of anything right on deploying test versus
Okay I will first admit I don't know the proper terminology for all this

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.