Advertisement
Jambix64

ExercicioTry_bhrow_catch

Aug 1st, 2016
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctype.h>
  3. using namespace std;
  4.   class announce{
  5.  
  6.   public:
  7.       void funcao(){
  8.  
  9.       cout<<"Erro!"<<endl;
  10.       }
  11.   };
  12. int main()
  13. {
  14.            try{ // Trata algo;
  15.            cout<<"Se voce Digitar algo no fora do intervalo entre 10 a 50 vai da error!"<<endl;
  16.            int num;
  17.            cin>>num;
  18.  
  19.            if(num>=10 && num<=50){
  20.  
  21.             cout<<("<<Number")<<"Esta no escopo "<<num<<endl;
  22.  
  23.            }else{
  24.  
  25.              throw num; // Vai lançar um erro;
  26.  
  27.         }
  28.  
  29.     }
  30.         catch (int initCatch){ // Vai pegar algo para tratar. Se o type ser diferente do tipo dentro do try dara erro;
  31.         cout<<"Error"<<endl;
  32.  
  33.         }
  34.  
  35.    return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement