Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #ifndef REQUESTAREA_H
  2. #define REQUESTAREA_H
  3.  
  4.  
  5. class RequestArea
  6. {
  7.     private:
  8.         std::string name;
  9.         int startArea;
  10.         int endArea;
  11.         enum accessType { read, write };
  12.         accessType type;
  13.     public:
  14.         RequestArea();
  15.         ~RequestArea();
  16.         void setRequest(std::string name, int startArea, int endArea, accessType type);
  17.         void getRequest();
  18.     protected:
  19.  
  20. };
  21.  
  22. #endif // REQUESTAREA_H
  23.  
  24. #include "RequestArea.h"
  25.  
  26. RequestArea::RequestArea()
  27. {
  28.     name = "";
  29.     startArea = 0;
  30.     endArea = 0;
  31.     type = read;
  32. }
  33.  
  34. void setRequest(std::string name, int startArea, int endArea, accessType type)
  35. {
  36.     this->name = name;
  37.     if(startArea < endArea)
  38.     {
  39.         this->startArea = startArea;
  40.         this->endArea = endArea;
  41.     }
  42.     else
  43.     {
  44.         cout << "Error in area!";
  45.         return 0;
  46.     }
  47.     this->type = type;
  48. }
  49.  
  50. void getRequest()
  51. {
  52.     cout << "name: " << name << endl;
  53.     cout << "startArea: " << startArea << endl;
  54.     cout << "endArea: " << endArea << endl;
  55.     cout << "access type is: " << type << endl << endl;
  56. }
  57.  
  58. RequestArea::~RequestArea()
  59. {
  60.     cout << "Destructor";
  61. }
  62.  
  63. #include <iostream>
  64. #include <RequestArea.h>
  65.  
  66. using namespace std;
  67.  
  68. int main()
  69. {
  70.     RequestArea area;
  71.     area.setRequest("name", 54, 128, read);
  72.     area.getRequest();
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement