Guest User

Untitled

a guest
Oct 25th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. class Entry
  6. {
  7. private:
  8. int age;
  9. int zip;
  10.  
  11. std::string name;
  12. std::string address;
  13. std::string city;
  14. std::string state;
  15. public:
  16. int ID;
  17.  
  18. Entry();
  19. Entry(int _age, int _zip, std::string _name, std::string _address, std::string _city, std::string _state);
  20.  
  21. void setAge(int _age) {age = _age;};
  22. void setZip(int _zip) {zip = _zip;};
  23. void setName(std::string _name) {name = _name;};
  24. void setAddress(std::string _address){address = _address;};
  25. void setCity(std::string _city) {city = _city;};
  26. void setState(std::string _state) {state = _state;};
  27.  
  28. int getAge() {return age;}
  29. int getZip() {return zip;}
  30. std::string getName() {return name;};
  31. std::string getAddress() {return address;};
  32. std::string getCity() {return city;};
  33. std::string getState() {return state;};
  34. };
  35.  
  36. Entry::Entry()
  37. {
  38. }
  39.  
  40. Entry::Entry(int _age, int _zip, std::string _name, std::string _address, std::string _city, std::string _state)
  41. {
  42. age = _age;
  43. zip = _zip;
  44. name = _name;
  45. address = _address;
  46. city = _city;
  47. state = _state;
  48. }
  49.  
  50. class Database
  51. {
  52. private:
  53. int uID;
  54. std::vector<Entry> tableEntries;
  55. public:
  56. Database();
  57.  
  58. void addEntry(Entry e);
  59. };
  60.  
  61. Database::Database()
  62. {
  63. uID = 0;
  64. }
  65.  
  66. void Database::addEntry(Entry e)
  67. {
  68. e.ID = uID;
  69. tableEntries.push_back(e);
  70.  
  71. uID++;
  72. }
  73.  
  74. int main()
  75. {
  76. Database db;
  77.  
  78. Entry test;
  79. test.setAge(12);
  80. test.setZip(1337);
  81. test.setName("Mark");
  82. test.setAddress("a");
  83. test.setCity("b");
  84. test.setState("c");
  85.  
  86. db.addEntry(test);
  87. db.addEntry(Entry(12, 1337, "using constructor", "a", "b", "c"));
  88. }
  89.  
Advertisement
Add Comment
Please, Sign In to add comment