 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Yoxoman Guest
|
Posted: Fri Feb 03, 2006 4:00 pm Post subject: references et objets fonctions |
|
|
Bonjour à tous.
Le code suivant ne compile ni sous g++ 3.4.2, ni sous comeau 4.3.3 :
#include <iostream>
#include <vector>
#include <iterator>
void str_acc(std::string& str_result, std::string s)
{
str_result += s;
}
int main()
{
std::vector<std::string> v;
std::string str_result;
v.push_back("test1");
v.push_back("test2");
std::for_each(v.begin(), v.end(),
std::bind1st(ptr_fun(&str_acc), str_result));
std::cout << str_result;
}
mais il marche en changeant la référence en pointeur dans les arguments
de str_acc.
Il semble y avoir un problème de référence sur référence.
Est-il interdit d'avoir des arguments de type référence dans les objets
fonctions ?
Ou des objets fonctions de tel type pour bind1st et bind2nd ?
Merci.
--
"Yo!"
Martin Heidegger |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|