Hands On C++17A Hands-On Self-Study Coursefor the Complete BeginnerDigital SkillsAlistair Stewart www.digital-skills.co.uk Hands On C++17Alistair Stewart Digital Skills MiltonBarrAyrshireKA26 9TYUKwww.Digital-Skills.co.uk www.digital-skills.co.uk tel: +44(0)1465 861 638 Copyright Digital Skills 2020 All rights reserved. No part of this work may be reproduced or used in any form without written permission from Digital Skills. Although every effort has been made to ensure accuracy, the author and publisher accept neither liability nor responsibility for any loss or damage arising from the information in this book. Cover image: NASA First Published March 2020 Title: Hands On C++17 ISBN: 978-1-874107-26-2 Comments Please take the time to help improve this book by emailing us any constructive comments you have on its contents. Any mistakes, omissions or suggests will be processed and where necessary the text will be updated. email: comments@digital-skills.co.uk Text Style In this text code is shown in blue monospaced type: in = GetUserInput()HandleUSerInput(in)HandleOther()Sync() as is any reference to C++-defined terms with the descriptive paragraphs. email: comments@digital-skills.co.uk Text Style In this text code is shown in blue monospaced type: in = GetUserInput()HandleUSerInput(in)HandleOther()Sync() as is any reference to C++-defined terms with the descriptive paragraphs.
Function names are always shown with terminating parentheses to distinguish them from variable names. C++ keywords, code, and function names are in bluemonospaced type while user-defined function names are shown in italics. Important terms, when used for the first time are shown in bold. Lines of code which, because of space restrictions, have had to be spread over two or more lines, start subsequent lines with the symbol this symbol is not part of the code. This text is designed primarily as a tutorial. As such many Activities build on work that has been carried out on previous pages, so jumping straight in to a specific section may sometimes make for a confusing read! Foreword - Alistair Stewart Welcome to the first edition of Hands On C++17.
Its more than 25 years since the original Hands On C++ book was published. Back then the text was written assuming you were using Borland C++. Unfortunately, Borland are no more, so this version covers only standard C++ and the programs should run with little or no change on any platform. However, the examples have been tested using Microsoft Visual C++ 2019 Community edition but care has been taken not to include any C++ extensions. The only parts of the text that are specific to Visual C++ are the few pages on using the IDE and creating a static library. The book has been written as an in-depth, hands-on, tutorial for anyone who is either starting out in programming in general or in C++ in particular.
How to Get the Most Out of this Book Is learning the basics of computer programming difficult? No, but you do have to put in the effort. Despite other publications promising to have you expert in a day, or a week, Im sure youre smart enough to know thats not going to happen. So, lets get real: youll learn how to program using C++17 if you put in the work, take your time to make sure you understand something before moving on, and practice, practice, practice. Weve tried to keep things interesting by giving you plenty of practical work to do as you journey through this book, but feel free to try out your own projects as well. The first two chapters are the only ones in which you wont be programming since they concentrate on the basic concepts behind all computer programming. You can, if you wish, work on the third chapter at the same time as you read through Chapters 1 and 2.
That way, youll be able to start programming right away. Take your time with each chapter. Make sure you do each of the activities: they are there to give you a deeper understanding as well as to keep you actively involved. Since most activities require you to create a program, the computer will let you know if youve got it right, but you should still take the time to look at the activitys solution given at the end of the chapter. The solution given may differ from your own but its always of use to see how others tackle the same problem. Support Material There are a few executable files accompanying this book. Support Material There are a few executable files accompanying this book.
These are designed as aids to the learning process but are not required for any of the programming exercises. You can download a ZIP file containing the support material from our website ( www.digital-skills.co.uk). Go to the Downloads page for C++ to find the link to the file. Thanks Id like to thank Virginia Marshall for making sure the English always made sense. Also, thanks to Alex Kladitis for his technical assistance and useful suggestions. 374 Testing Functions .........................................................................................376 Introduction ...........................................................................................376 Black Box Testing ..................................................................................376 Boundary Testing ..................................................................................378 White Box Testing .................................................................................379 Combining Test Requirements ............................................................379 Test Drivers ............................................................................................381 Function Complexity ............................................................................382 Summary ................................................................................................384 Solutions ........................................................................................................385
Next page