Bonjour,

Je bute un peu sur les références, voici un cas que je n'arrive pas
à comprendre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
void manipString(string &str)
{  
 //......
}
 
 
string stringReturn()
{
   string str = "Hello world !";
   return str;
}
 
 
int main()
{
 
  manipString(stringReturn());
 
}
Le compilo me dit :
error:invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::string'

error:in passing argument 1 of `void manipString(std::string&)
En clair, est il possible de passer a une fonction qui prend en paramètre
une référence sur string, une fonction qui retourne une string ?

Merci