Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string>
- using namespace std;
- double function1 (double x, double y){
- if (y==0){
- string wyjatek="Dzielenie przez zero! ";
- throw wyjatek;
- }
- return x/y;
- };
- double function2(void){
- try{
- std::cout <<"Sprawdzam wyjatek dzielenia przez zero:" <<endl;
- function1(4,0);
- }catch(string o1){
- cout <<"Wyjatek: " <<o1;
- }
- return -1;
- };
- int main(){
- double x=function1(5,3);
- cout <<x <<endl;
- double y=function2();
- cout <<y <<endl;
- double z=function1(7,7);
- cout <<z <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement