fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4.  
  5. class data
  6. {
  7. private:
  8. int first_int_;
  9. int second_int_;
  10. std::string chars_;
  11. float float_value_;
  12.  
  13. public:
  14. data(int first_int, int second_int, const std::string& chars, float float_value)
  15. :first_int_(first_int)
  16. ,second_int_(second_int)
  17. ,chars_(chars)
  18. ,float_value_(float_value)
  19. {
  20. }
  21.  
  22. void print(std::ostream& os) const
  23. {
  24. os << "val1 = "
  25. << first_int_
  26. << ", val2 = "
  27. << second_int_
  28. << ", val3-5 = "
  29. << chars_
  30. << ", val6 = "
  31. << std::setprecision(3)
  32. << float_value_
  33. << std::endl;
  34. }
  35.  
  36. };
  37.  
  38. int main ()
  39. {
  40. data d(4, 56, "tes", 3.14f);
  41. d.print(std::cout);
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
val1 = 4, val2 = 56, val3-5 = tes, val6 = 3.14