fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Sample
  5. {
  6. Sample(int a, int b): a(a), b(b)
  7. {
  8. }
  9.  
  10. void bar() const
  11. {
  12. cout << a << ", " << b << endl;
  13. }
  14.  
  15. int a, b;
  16. };
  17.  
  18. void foo(const Sample& s)
  19. {
  20. s.bar();
  21. }
  22.  
  23. int main() {
  24.  
  25. foo(Sample{1, 2});
  26. foo(Sample(1, 2));
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
1, 2
1, 2