for(auto &c:s)與for(auto c:s)

在c11標準下能夠執行的特殊格式的for循環語句,區別在於引用類型能夠改變原來的值ios #include<iostream> using  namespace  std; int  main() {      string  s( "hello world" );      for (auto c:s)      c= 't' ;      cout<<s<<endl; //結果爲hello w
相關文章
相關標籤/搜索