logo资料库

C++17 By Example.pdf

第1页 / 共433页
第2页 / 共433页
第3页 / 共433页
第4页 / 共433页
第5页 / 共433页
第6页 / 共433页
第7页 / 共433页
第8页 / 共433页
资料共433页,剩余部分请下载后查看
Cover
Copyright and Credits
Dedication
Packt Upsell
Contributors
Table of Contents
Preface
Chapter 1: Getting Started with C++
Rolling the dice
Understanding classes – the Car class
Extending the Car class
A class hierarchy – the Person, Student, and Employee classes
A simple data type – the stack
A more advanced data type – the queue
Summary
Chapter 2: Data Structures and Algorithms
The List class
The Cell class
The Iterator class
The List class
Adding a list to an existing list
Erasing a value from the list
The Set class
Union, intersection, and difference operations
Basic searching and sorting
The select sort algorithm
The insert sort algorithm
The bubble sort algorithm
The extended List class
The ReverseIterator class
The extended Set class
Union, intersection, and difference
Advanced searching and sorting
The merge sort algorithm
The quick sort algorithm
Summary
Chapter 3: Building a Library Management System
The Book class
Writing the book
Reading the book
Borrowing and reserving the book
Displaying the book
The Customer class
Reading the customer from a file
Writing the customer to a file
Borrowing and reserving a book
Displaying the customer
The Library class
Looking up books and customers
Adding a book
Deleting a book
Listing the books
Adding a customer
Deleting a customer
Listing the customers
Borrowing a book
Reserving a book
Returning a Book
Saving the library information to a file
Loading the library information from a file
The main function
Summary
Chapter 4: Library Management System with Pointers
The Book class
Reading and writing the book
Borrowing and reserving the book
Displaying the book
The Customer class
Reading and writing the customer
Borrowing and reserving a book
Displaying the customer
The Library class
Looking up books and customers
Adding a book
Deleting a book
Listing the books
Adding a customer
Deleting a customer
Listing the customers
Borrowing a book
Reserving a book
Returning a book
Looking up books and customers
Marshmallowing
Saving the library information to a file
Writing the book objects
Writing the customer objects
Writing the borrower index
Writing the reservation indexes
Writing the loan book indexes
Writing the reservation book indexes
Loading the library information from a file
Reading the book objects
Reading the customer objects
Reading the borrower index
Reading the reservation indexes
Reading the loan book indexes
Reading the reservation book indexes
Deallocating memory
The main function
Summary
Chapter 5: Qt Graphical Applications
Creating the clock application
Setting up the environment
The Clock class
The main function
Setting up reusable classes for windows and widgets
Adding a listener
The base window class
The base widget class
Building the drawing program
The Figure base class
The Line sub class
The Rectangle sub class
The Ellipse sub class
Drawing the window
Drawing the widget
The main function
Building an editor
The Caret class
Drawing the editor window
Drawing the editor widget
The main function
Summary
Chapter 6: Enhancing the Qt Graphical Applications
Improving the clock
The Clock class
The main function
Improving the drawing program
The Figure class
The Line class
The Rectangle class
The Ellipse class
The DrawingWindow class
The DrawingWidget class
The main function
Improving the editor
The EditorWindow class
The EditorWidget class
The main function
Summary
Chapter 7: The Games
Othello
The game widget
The OthelloWindow class
The OthelloWidget class
The main function
Noughts and crosses
The NaCWindow class
The NaCWidget class
The main function
Summary
Chapter 8: The Computer Plays
Othello
The OthelloWindow class
The OthelloWidget Class
The main function
Noughts and Crosses
The NaCWindow class
The NaCWidget class
The main function
Summary
Chapter 9: Domain-Specific Language
Introducing the source language – a simple example
The grammar of the source language
The target language
The colors
Error handling
The value
The scanner
Building the parser
Parsing the instructions of the language
Parsing the expressions of the language
Type checking the expression
Evaluating the values of the expressions
The viewer
The main function
Summary
Chapter 10: Advanced Domain-Specific Language
Improving the source language – an example
Improving the grammar
The Token and the Scanner
The parser
The evaluator
The main function
Summary
Other Books You May Enjoy
Index
C++17 By Example Practical projects to get you up and running with C++17 Stefan Björnander BIRMINGHAM - MUMBAI
C++17 By Example Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Merint Mathew Acquisition Editor: Chaitanya Nair Content Development Editor: Lawrence Veigas Technical Editor: Adhithya Haridas Copy Editor: Safis Editing Project Coordinator: Prajakta Naik Proofreader: Safis Editing Indexer: Aishwarya Gangawane Graphics: Jisha Chirayil Production Coordinator: Deepika Naik First published: February 2018 Production reference: 1220218 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78839-181-8 www.packtpub.com
I dedicate this book to my parents, Ralf and Gunilla, my sister, Catharina, her husband, Magnus, and their sons, Emil and Rasmus.
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors About the author Stefan Björnander is the author of the books Microsoft Windows C++ and C++ Windows Programming. He holds a Master of Engineering and a Licentiate in Computer Science. He has worked as a software developer and as a teacher in computer science and mathematics for many years.
About the reviewer Mark Elston is a software architect for an automated test equipment company working primarily in the IC and mobile device test world. However, his 30 years of experience includes developing aircraft and missile simulations for the Air Force and Navy, hardware control systems for NASA, and tester operating systems for commercial products. He has also developed several Android applications for fun. His latest passion is delving into the world of functional programming and design. I would like to thank my wife for her understanding when I had a chapter to finish reviewing. I would also like to thank the Pack team for giving me the opportunity to work with them on this project. It has been enlightening and entertaining. Finally, I would like to thank the author for taking even my smallest comments into account. It is a pleasure to be part of a project where your input is valued. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Table of Contents Preface Chapter 1: Getting Started with C++ Rolling the dice Understanding classes – the Car class Extending the Car class A class hierarchy – the Person, Student, and Employee classes A simple data type – the stack A more advanced data type – the queue Summary Chapter 2: Data Structures and Algorithms 1 6 7 14 20 24 29 33 36 37 38 38 39 41 46 48 51 57 59 60 61 62 65 67 82 84 89 90 92 93 The List class The Cell class The Iterator class The List class Adding a list to an existing list Erasing a value from the list The Set class Union, intersection, and difference operations Basic searching and sorting The select sort algorithm The insert sort algorithm The bubble sort algorithm The extended List class The ReverseIterator class The extended Set class Union, intersection, and difference Advanced searching and sorting The merge sort algorithm The quick sort algorithm Summary
分享到:
收藏