Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include "ex05.hpp"
  3.  
  4. int float_to_int(float const& f) {
  5. return static_cast<int>(f);
  6. }
  7. int main()
  8. {
  9. array<int> a(4);
  10. a[3] = 1;
  11. const array<int> b = a;
  12. b.dump();
  13. array<float> c;
  14. c.dump();
  15. c[2] = 1.1;
  16. c.dump();
  17. a = c.convertTo<int>(&float_to_int);
  18. a.dump();
  19.  
  20. array<bool> bo(5);
  21. bo[2] = true;
  22. bo.dump();
  23.  
  24. const array<int> co(2);
  25. try {
  26. co[10] = 2;
  27. }
  28. catch(std::exception & e) {
  29. std::cout << "catched!!" << std::endl;
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement