Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include "Rectangle.h"
  3.  
  4. namespace Shape {
  5.     class NemFerBele : public std::exception {
  6.         const char *what() const throw() {
  7.             return "Nem fér bele a négyzet";
  8.         }
  9.     };
  10.  
  11.     template<class T>
  12.     void fit(T &a, T &b) {
  13.         if (a < b) {
  14.             std::cout << "Belefer";
  15.         } else {
  16.             throw NemFerBele();
  17.         }
  18.     }
  19. }
  20.  
  21. int main() {
  22.  
  23.     Shape::Rectangle square(10.0, 10.0);
  24.     Shape::Rectangle square2(11.0, 9.0);
  25.  
  26.     try {
  27.         Shape::fit(square, square2);
  28.     } catch (std::exception &e) {
  29.         std::cout << e.what() << std::endl;
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement