Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class E_BAZA
- {
- public : virtual void wypisz()=0;
- virtual ~E_BAZA(){}
- };
- ///////////////////////////////////////////////////////////////////////////////////////
- class E_DZIELENIE_ZERA: public E_BAZA
- {
- public: void wypisz()
- {
- cout<<"Dzielenia zera"<<endl;
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- };
- class E_DZIELENIE_PRZEZ_ZERO: public E_BAZA
- {
- public: void wypisz()
- {
- cout<<"Dzielenie przez zereo"<<endl;
- }
- };
- ////////////////////////////////////////////////////////////////////////////////////////
- double dziel(double x, double y)throw (E_DZIELENIE_ZERA,E_DZIELENIE_PRZEZ_ZERO)//TO JEST WSPOLCZESNY NAGLOWEK FUNKCJI
- {
- if(x==0)
- {
- E_DZIELENIE_ZERA w;
- throw (w);
- }
- if(y==0)
- {
- E_DZIELENIE_PRZEZ_ZERO w;
- throw (w);
- }
- return x/y;
- }
- int main(int argc, char** argv)
- {
- // PROGRAMOWANIE OFENSYWNE
- try
- {
- cout<<dziel(6,0)<<endl;
- }
- catch (E_BAZA &w) //referencja wymagana
- {
- w.wypisz();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement