Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3.  
  4. struct Foo
  5. {
  6.     Foo(std::string texte) : _texte(texte)
  7.     {
  8.         std::cout << _texte << std::endl;
  9.     }
  10.     void ecrire(const std::string& texte)
  11.     {
  12.         _texte = texte;
  13.         std::cout << _texte << std::endl;
  14.     }
  15.  
  16.     std::string &_texte;
  17. };
  18.  
  19. struct Bar
  20. {
  21.     void ecrire(Foo &foo)
  22.     {
  23.         std::string text("mon texte");
  24.         foo.ecrire(text);
  25.     }
  26. };
  27.  
  28. int _tmain(int argc, _TCHAR* argv[])
  29. {
  30.     Bar bar;
  31.     Foo foo("init");
  32.  
  33.     bar.ecrire(foo);
  34.  
  35.     std::cout << foo._texte << std::endl;
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement