fork download
  1. #include <stdexcept>
  2. #include <cstring>
  3. class Sales
  4. {
  5. public:
  6. enum {MONTHS = 12} ; // Może być stalą statyczną
  7. class bad_index: public std::logic_error
  8. {
  9. private:
  10. int bi; //Zla wartość indeksu
  11. public:
  12. explicit bad_index(int ix,
  13. const char * s = "Niepoprawny indeks w obiekcie klasy Sales\n");
  14. int bi_val() const
  15. {
  16. return bi;
  17. }
  18. };
  19. explicit Sales(int yy = 0 ) ;
  20. Sales(int yy, const double * gr , int n ) ;
  21. virtual ~Sales () { }
  22. int Year () const
  23. {
  24. return year;
  25. }
  26. virtual double operator[] (int i) const throw(std::logic_error);
  27. virtual double & operator[](int i) throw(std::logic_error);
  28. private:
  29. double gross[MONTHS] ;
  30. int year;
  31. };
  32.  
  33. class LabeledSales : public Sales
  34. {
  35. public:
  36. static const int STRLEN = 50; //Może być wyliczeniem
  37. class nbad_index : public Sales::bad_index
  38. {
  39. private:
  40. char lbl[STRLEN];
  41. public:
  42. nbad_index(const char * lb, int ix,
  43. const char * s = "Niepoprawny indeks w obiekcie klasy LabeledSales\n");
  44. const char * label_val()
  45. {
  46. return lbl;
  47. }
  48. };
  49. explicit LabeledSales (const char * lb = "brak", int yy = 0 ) ;
  50. LabeledSales (const char * ib, int yy, const double * gr, int n) ;
  51. virtual ~LabeledSales() {}
  52. const char * Label () const
  53. {
  54. return label;
  55. }
  56. virtual double operator[](int i) const throw(std::logic_error);
  57. virtual double & operator[](int i) throw(std::logic_error);
  58. private:
  59. char label[STRLEN];
  60. };
  61.  
  62. int main(){}
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty