Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class E_BAZA
  4. {
  5. public : virtual void wypisz()=0;
  6. virtual ~E_BAZA(){}
  7. };
  8. ///////////////////////////////////////////////////////////////////////////////////////
  9. class E_DZIELENIE_ZERA: public E_BAZA
  10. {
  11. public: void wypisz()
  12. {
  13. cout<<"Dzielenia zera"<<endl;
  14. }
  15. ///////////////////////////////////////////////////////////////////////////////////////
  16. };
  17. class E_DZIELENIE_PRZEZ_ZERO: public E_BAZA
  18. {
  19. public: void wypisz()
  20. {
  21. cout<<"Dzielenie przez zereo"<<endl;
  22. }
  23.  
  24. };
  25. ////////////////////////////////////////////////////////////////////////////////////////
  26. double dziel(double x, double y)throw (E_DZIELENIE_ZERA,E_DZIELENIE_PRZEZ_ZERO)//TO JEST WSPOLCZESNY NAGLOWEK FUNKCJI
  27. {
  28. if(x==0)
  29. {
  30. E_DZIELENIE_ZERA w;
  31. throw (w);
  32. }
  33.  
  34. if(y==0)
  35. {
  36. E_DZIELENIE_PRZEZ_ZERO w;
  37. throw (w);
  38. }
  39.  
  40. return x/y;
  41.  
  42. }
  43.  
  44.  
  45. int main(int argc, char** argv)
  46. {
  47. // PROGRAMOWANIE OFENSYWNE
  48. try
  49. {
  50. cout<<dziel(6,0)<<endl;
  51.  
  52. }
  53. catch (E_BAZA &w) //referencja wymagana
  54. {
  55. w.wypisz();
  56.  
  57. }
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement