fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Beispiel {
  5. public:
  6. Beispiel(std::string &str) { mStr = &str; }
  7. void tueWasMitString() { *mStr += "AAA"; }
  8.  
  9. private:
  10. std::string *mStr;
  11. };
  12.  
  13. int main() {
  14.  
  15. std::string test = "BBB";
  16. Beispiel b(test);
  17. b.tueWasMitString();
  18.  
  19. std::cout << test; // soll "BBBAAA"
  20. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
BBBAAA