Trouble in modifying last element of a std::list [on hold]

I am trying to modify the last element of a list of integers (mylist) as

 //0 1 2 3 4 5 list initially         list<int>::reference p=mylist.back();   p=p+10;  //Now iterating over the list gives   //0 1 2 3 4 15 

Using the above code I get the job done but when I use auto it doesn't change the last element.

 //0 1 2 3 4 5 list initially         auto p=mylist.back();   p=p+10;  //Now iterating over the list gives   //0 1 2 3 4 5 

As per my understanding auto detects the return type of mylist.back() here as list<int>::reference,so why is this difference occurring and what could be the possible explanation for this?

Replay

Category: c# Time: 2016-07-30 Views: 0
Tags: reference

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.166 (s). 12 q(s)