fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void foo(string&& bar){
  6. string* temp = &bar;
  7. // bar = "wo";
  8. cout << *temp << " @:" << temp << endl;
  9. cout << "bar = " << bar <<endl;
  10. }
  11.  
  12. int main() {
  13. // your code goes here
  14. string a = "hello";
  15. string& ra = a;
  16. string* tmp = &ra;
  17. // string b(std::move(a));
  18. cout<< *tmp << "@:" << tmp << " " << a << "@:" << &a << endl;
  19. foo(std::move(a));
  20. cout << "a = " << a << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
hello@:0x7ffcd8017dd0  hello@:0x7ffcd8017dd0
hello @:0x7ffcd8017dd0
bar = hello
a = hello