Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- class Entry
- {
- private:
- int age;
- int zip;
- std::string name;
- std::string address;
- std::string city;
- std::string state;
- public:
- int ID;
- Entry();
- Entry(int _age, int _zip, std::string _name, std::string _address, std::string _city, std::string _state);
- void setAge(int _age) {age = _age;};
- void setZip(int _zip) {zip = _zip;};
- void setName(std::string _name) {name = _name;};
- void setAddress(std::string _address){address = _address;};
- void setCity(std::string _city) {city = _city;};
- void setState(std::string _state) {state = _state;};
- int getAge() {return age;}
- int getZip() {return zip;}
- std::string getName() {return name;};
- std::string getAddress() {return address;};
- std::string getCity() {return city;};
- std::string getState() {return state;};
- };
- Entry::Entry()
- {
- }
- Entry::Entry(int _age, int _zip, std::string _name, std::string _address, std::string _city, std::string _state)
- {
- age = _age;
- zip = _zip;
- name = _name;
- address = _address;
- city = _city;
- state = _state;
- }
- class Database
- {
- private:
- int uID;
- std::vector<Entry> tableEntries;
- public:
- Database();
- void addEntry(Entry e);
- Entry viewEntry(int i);
- };
- Database::Database()
- {
- uID = 0;
- }
- void Database::addEntry(Entry e)
- {
- e.ID = uID;
- tableEntries.push_back(e);
- uID++;
- }
- Entry Database::viewEntry(int i)
- {
- return tableEntries.at(i);
- }
- int main()
- {
- Database db;
- Entry test;
- test.setAge(12);
- test.setZip(1337);
- test.setName("Mark");
- test.setAddress("a");
- test.setCity("b");
- test.setState("c");
- db.addEntry(test);
- db.addEntry(Entry(12, 1337, "using constructor", "a", "b", "c"));
- Entry vEntry = db.viewEntry(0);
- std::cout << vEntry.getName() << std::endl;
- system("pause");
- }
Add Comment
Please, Sign In to add comment