fork download
  1. #include <iostream>
  2.  
  3. class A {
  4. public:
  5. A(int i) : i_(i){
  6. std::cout << "A() is constructed (this = " << static_cast<void*>(this) << ")\n";
  7. }
  8. ~A() {
  9. std::cout << "A() is destructed (this = " << static_cast<void*>(this) << ")\n";
  10. }
  11. void hello() {
  12. std::cout << "Hello from A! (this = " << static_cast<void*>(this) << ")\n";
  13. }
  14. private:
  15. int i_;
  16. };
  17.  
  18. void hello(A& a) {
  19. return a.hello();
  20. }
  21.  
  22. int main() {
  23. A a((hello(a),42));
  24. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Hello from A! (this = 0x7ffe5cdbd060)
A() is constructed (this = 0x7ffe5cdbd060)
A() is destructed (this = 0x7ffe5cdbd060)