Using polymorphism
In the following example, we will create code that simulates a team of C++ developers. The code will use interfaces to decouple the classes so that it is possible to change the services that a class uses without changing that class. In this simulation, we have a manager managing a team, so a property of the manager is their team. Further, every worker, whether a manager or a team member have some common properties and behaviors--they all have a name and a job position and they all do work of some kind.
Create a folder for the chapter and in that folder, create a file called team_builder.cpp
, and since this application will use a vector
, smart pointers, and files, add the following lines to the top of the file:
#include <iostream> #include <string> #include <vector> #include <fstream> #include <memory> using namespace std;
The application will have command-line parameters, but for the time being, just provide an empty...