fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct A
  5. {
  6. private:
  7. int m_v;
  8. std::string m_n;
  9. public:
  10. A(int,std::string);
  11. A(float);
  12. };
  13.  
  14. A::A(int v,std::string n) : m_v(v),m_n{n} // 1
  15. {
  16. }
  17.  
  18. A::A(float) : A{-1,"float"} // 2
  19. {
  20.  
  21. }
  22.  
  23. int main() {
  24. A ap(42,"0"); // 3
  25. A ab{42,"0"}; // 4
  26.  
  27. A bp = A(42,"0"); // 5
  28. A bb = A{42,"0"}; // 6
  29.  
  30. //A cp = (42,"0"); // 7 error
  31. A cb = {42,"0"}; // 8
  32.  
  33. A dp = (42,0.0); // 9
  34. //A dp = {42,0.0}; // 10 error
  35.  
  36. double pi = 3.1415926535;
  37. A ep(pi); // 11
  38. //A eb{pi}; // 12 error
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5524KB
stdin
Standard input is empty
stdout
Standard output is empty