|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Oct 2003
Città: Pisa/Cosenza
Messaggi: 1364
|
[C++] Il modo migliore di passare una stringa
Ciao, volevo sapere qual è il modo migliore di passare una stringa ad un metodo che non la modifica.
Codice:
metodo(const string& s) ?? Se modifico vari metodi a cui prima passavo una stringa in questo modo: Codice:
metodo(string s) Spiego meglio: Se ho un metodo fun(string s) e lo trasformo in fun(const string& s) posso lasciare la sua invocazione così: Codice:
string x = "test"; fun(x);
__________________
![]() |
![]() |
![]() |
![]() |
#2 | ||
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Quote:
[quote] Se modifico vari metodi a cui prima passavo una stringa in questo modo: Codice:
metodo(string s) [quote] Basta cambiare la signature Quote:
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
||
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Oct 2003
Città: Pisa/Cosenza
Messaggi: 1364
|
Grazie, troppo gentile.
![]()
__________________
![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 18:07.