3. Built-in Data Types
Activity 3: Sign-Up Application
Solution:
- Start by including the various headers that the application will need:
// Activity 3: SignUp Application. #include <iostream> #include <string> #include <vector> #include <stdexcept>
- Next, define the class that will represent a record in the system. This is going to be a person, containing both a name and an age. Also, declare a vector of this type to store these records. A vector is used for the flexibility it gives in not having to declare an array size upfront:
struct Person { int age = 0; std::string name = ""; }; std::vector<Person> records;
- Now, you can start adding some functions to add and fetch records; first, add. A record consists of a name and age, so write a function that will accept those two as parameters, create a record object, and add it to our record vector. Name this function
AddRecord
:void AddRecord...