Don't like ads? PRO users don't see any ads ;-)
Guest

wyjatki.h

By: a guest on Apr 29th, 2012  |  syntax: C++  |  size: 1.03 KB  |  hits: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #pragma once
  2.  
  3. #include <iostream>
  4. #include "reader.h"
  5.  
  6. using namespace std;
  7.  
  8. struct xcp_wrong_type
  9. {
  10.         char* was;
  11.         char* should_be;
  12.  
  13.         xcp_wrong_type(const char* m1, const char* m2)
  14.         {
  15.                 was = new char[strlen(m1)+1];
  16.                 strcpy(was,m1);
  17.                 should_be = new char[strlen(m2)+1];
  18.                 strcpy(should_be,m2);
  19.         }
  20.  
  21.         xcp_wrong_type(const xcp_wrong_type& t)
  22.         {
  23.                 was = new char[strlen(t.was)+1];
  24.                 strcpy(was, t.was);
  25.                 should_be = new char[strlen(t.should_be)+1];
  26.                 strcpy(should_be, t.should_be);
  27.         }
  28.  
  29.         ~xcp_wrong_type()
  30.         {
  31.                 delete [] was;
  32.                 delete [] should_be;
  33.         }
  34.  
  35.         void opis()
  36.         {
  37.                 cout << "Podales: " << was << ", a powinno byc typu: " << should_be << endl;
  38.         }
  39. };
  40.  
  41.  
  42. struct xcp_value
  43. {
  44.         void opis()
  45.         {
  46.                 cout << "Podana liczba przekracza 40000." << endl;
  47.         }
  48. };
  49.  
  50.  
  51. struct xcp_division_by_zero
  52. {
  53.         char* number;
  54.  
  55.         xcp_division_by_zero(const char* n)
  56.         {
  57.                 number = new char[strlen(n)+1];
  58.                 strcpy(number,n);
  59.         }
  60.  
  61.         void opis()
  62.         {
  63.                 cout << "Nie mozna dzielic liczby " << number << " przez 0." << endl;
  64.         }
  65. };