Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Beginning C++ Programming

You're reading from   Beginning C++ Programming Modern C++ at your fingertips!

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher Packt
ISBN-13 9781787124943
Length 526 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Richard Grimes Richard Grimes
Author Profile Icon Richard Grimes
Richard Grimes
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Starting with C++ 2. Understanding Language Features FREE CHAPTER 3. Exploring C++ Types 4. Working with Memory, Arrays, and Pointers 5. Using Functions 6. Classes 7. Introduction to Object-Orientated Programming 8. Using the Standard Library Containers 9. Using Strings 10. Diagnostics and Debugging

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image