C++ for Lazy Programmers -  Will Briggs

C++ for Lazy Programmers (eBook)

Quick, Easy, and Fun C++ for Beginners

(Autor)

eBook Download: PDF
2019 | 1st ed.
XXVII, 644 Seiten
Apress (Verlag)
978-1-4842-5187-4 (ISBN)
Systemvoraussetzungen
46,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen
Learn C++ the quick, easy, and 'lazy' way. This book is an introductory programming text that uses humor and fun to make you actually willing to read, and eager to do the projects -- with the popular C++ language.

C++ for Lazy Programmers is a genuinely fun learning experience that will show you how to create programs in the C++ language. This book helps you learn the C++ language with a unique method that goes beyond syntax and how-to manuals and helps you understand how to be a productive programmer. It provides detailed help with both the Visual Studio and g++ compilers plus their debuggers, and includes the latest version of the language, C++17, too.  

Along the way you'll work through a number of labs: projects intended to stretch your abilities, test your new skills, and build confidence. You'll go beyond the basics of the language and learn how build a fun C++ arcade game project. After reading and using this book, you'll be ready for your first real-world C++ application or game project on your own.  


What You Will Learn
  • Program for the first time in C++ in a fun, quick and easy manner
  • Discover the SDL graphics and gaming library
  • Work with SSDL, the Simple SDLwrapper library
  • Use the most common C++ compilers: Visual Studio, and g++ (with Unix or MinGW)
  • Practice 'anti-bugging' for easy fixes to common problems 
  • Work with the debugger
  • Acquire examples-driven concepts and ideas 
  • Build a C++-based arcade game application 
  • Apply built-in Standard Template Library (STL) functions and classes for easy and efficient programming
  • Dip your toe in C, C++'s ancestor, still extensively used in industry
  • Use new C++11/14/17 features including lambda functions, constexpr, and smart pointers

Who This Book Is For

Those who are new to C++, either as a guide for self-learners or as an accessible textbook for students in college-level courses.  



Will Briggs, PhD is a professor of computer science at the University of Lynchburg in Virginia.  He has 20+ years of experience teaching C++, 12 of them using earlier drafts of this book, and about as many years teaching other languages including C, LISP, Pascal, PHP, PROLOG, and Python.  His primary focus is teaching of late while also active in research in artificial intelligence.

Learn C++ the quick, easy, and "e;lazy"e; way. This book is an introductory programming text that uses humor and fun to make you actually willing to read, and eager to do the projects -- with the popular C++ language.C++ for Lazy Programmers is a genuinely fun learning experience that will show you how to create programs in the C++ language. This book helps you learn the C++ language with a unique method that goes beyond syntax and how-to manuals and helps you understand how to be a productive programmer. It provides detailed help with both the Visual Studio and g++ compilers plus their debuggers, and includes the latest version of the language, C++17, too.  Along the way you'll work through a number of labs: projects intended to stretch your abilities, test your new skills, and build confidence. You'll go beyond the basics of the language and learn how build a fun C++ arcade game project. After reading and using this book, you'll be ready for your first real-world C++ application or game project on your own.  What You Will LearnProgram for the first time in C++ in a fun, quick and easy mannerDiscover the SDL graphics and gaming libraryWork with SSDL, the Simple SDLwrapper libraryUse the most common C++ compilers: Visual Studio, and g++ (with Unix or MinGW)Practice "e;anti-bugging"e; for easy fixes to common problems Work with the debuggerAcquire examples-driven concepts and ideas Build a C++-based arcade game application Apply built-in Standard Template Library (STL) functions and classes for easy and efficient programmingDip your toe in C, C++'s ancestor, still extensively used in industryUse new C++11/14/17 features including lambda functions, constexpr, and smart pointersWhoThis Book Is ForThose who are new to C++, either as a guide for self-learners or as an accessible textbook for students in college-level courses.  

Table of Contents 5
About the Author 17
About the Technical Reviewer 18
Acknowledgments 19
Introduction 21
Chapter 1: Getting Started 26
A simple program 26
Spacing 29
Creating an SSDL project 31
…in Visual Studio 31
Compiling your program 32
The files you created 36
Reopening your project 39
Antibugging 39
…with g++ 42
The files you created 43
Cool command-line tricks 43
Antibugging 44
How not to be miserable 44
Shapes and the functions that draw them 46
Antibugging 55
consts and colors 56
Text 60
sout, escape sequences, and fonts 60
SSDL_RenderText, SSDL_RenderTextCentered 64
Chapter 2: Images and Sound 68
Images and changing window characteristics 68
Antibugging 74
Multiple images together 76
Adding transparency with GIMP 77
Sound 82
Antibugging 85
Chapter 3: Numbers 86
Variables 86
Constants 88
When to use constants, not literal values 89
Math operators 90
Integer division 90
Assignment (=) operators 91
A diving board example 92
The no-worries list for math operators 95
Built-in functions and casting 96
Antibugging 101
Chapter 4: Mouse, and if 104
Mouse functions 104
Antibugging 107
if 108
Coercion and if conditions (int’s dirty little secret) 111
Combining conditions with & &
Antibugging 112
Boolean values and variables 115
A hidden object game 117
Chapter 5: Loops, Input, and char 125
Keyboard input 125
Antibugging 127
while and do-while 129
Loops with SSDL 131
break and continue 132
Antibugging 133
for loops 136
Increment operators 137
An example: averaging numbers 138
Antibugging 140
chars and cctype 142
switch 147
Antibugging 148
Chapter 6: Algorithms and the Development Process 150
Adventures in robotic cooking 150
Writing a program, from start to finish 154
Requirements: What do we want to do? 154
Algorithm: How do we do it? 155
Walkthrough: Will it do it? 157
Coding: putting it all into C++ (plus: commenting the lazy way) 157
Chapter 7: Functions 163
Functions that return values 163
Functions that return nothing 170
Global variables 174
Antibugging 175
How to write a function in four easy steps (and call it in one) 178
Why have functions, anyway? 182
Chapter 8: Functions (Continued) 193
Random numbers 193
Making a random number generator 193
Using the built-in random number generator 196
Antibugging 199
Boolean functions 201
& parameters
Antibugging 207
Identifier scope 208
A final note on algorithms 211
Chapter 9: Using the Debugger 212
A flawed program 212
Breakpoints and watched variables 217
Visual Studio 217
ddd 219
gdb 220
Fixing the stripes 220
Going into functions 220
Visual Studio 220
ddd 222
gdb 223
Fixing the stars 223
Wrap-up 224
Antibugging 224
Bottom-up testing 225
More on antibugging 226
Chapter 10: Arrays and enum 228
Arrays 228
Arrays’ dirty little secret: using memory addresses 231
Antibugging 232
Arrays as function parameters 233
Array parameters that change, or don’t 234
Array parameters and reusability 234
Antibugging 235
Enumeration types 236
enum class 238
Antibugging 239
Multidimensional arrays 240
Displaying the board 241
Arrays of more than two dimensions 244
Antibugging 245
Chapter 11: Animation with structs and Sprites 247
structs 247
Cool struct tricks 251
Making a movie with struct and while 252
Sprites 259
Antibugging 264
Chapter 12: Making an Arcade Game: Input, Collisions, and Putting It All Together 265
Determining input states 265
Mouse 265
Keyboard 266
Antibugging 268
Events 268
Cooldowns and lifetimes 271
Collisions 274
The big game 275
Antibugging 289
Chapter 13: Standard I/O and File Operations 293
Standard I/O programs 293
Compiling in Microsoft Visual Studio 294
Antibugging 297
Compiling with g++ 298
Antibugging 300
File I/O (optional) 300
cin and cout as files 300
Getting the command prompt in Windows 300
Redirecting I/O at the command prompt 302
while (cin) 302
Reading in characters, including whitespace 304
Antibugging 305
Using file names 307
Chapter 14: Character Arrays and  Dynamic Memory 313
Character arrays 313
Antibugging 316
Dynamic allocation of arrays 319
Antibugging 322
Using the * notation 323
Antibugging 327
Chapter 15: Classes 329
Writing classes 329
Constructors 332
Antibugging 336
const objects, const member functions… 338
Antibugging 339
…and const parameters 339
Multiple constructors 340
Copy constructors 340
Default constructors 341
Conversion constructors 342
Summary 343
Antibugging 343
Default parameters for code reuse 344
Date program (so far) 345
Chapter 16: Classes (Continued) 348
inline functions for efficiency 348
Access functions 350
Separate compilation and include files 351
What happens in separate compilation 352
Writing your .h file 353
Including a .h file only once 354
Avoid using namespace std in include files
Constants in include files 356
Backing up a multi-file project 356
Antibugging 356
Multiple-file projects in Microsoft Visual Studio 358
Multiple-file projects in g++ 359
Command line: more typing, less thinking 359
Makefiles: more thinking, less typing 359
A simple version 359
A better version 360
Antibugging 363
Final Date program 363
static members (optional) 369
Chapter 17: Operators 372
The basic string class 372
Destructors 374
Binary and unary operators 375
Assignment operators and * this 377
Antibugging 379
Arithmetic operators 380
[] and () 383
> >
++ and -- 387
Explicit call to constructor 388
Final String program 389
#include < string>
Chapter 18: Exceptions, Move Constructors, Recursion, and O Notation 396
Exceptions 396
Move constructors and move = (optional) 401
Recursion (optional used in the next section)
Antibugging 407
Algorithm analysis and O notation (optional) 408
Chapter 19: Inheritance 412
The basics of inheritance 412
Constructors and destructors 417
Inheritance as a concept 419
Classes for card games 420
An inheritance hierarchy 423
private inheritance 427
Hiding an inherited member function 429
A game of Montana 430
Chapter 20: Templates 441
Function templates 441
Antibugging 443
The Vector class 444
Efficiency (optional) 449
Making Vector a template 450
Antibugging 454
Unusual class templates 455
#include < vector>
Chapter 21: Virtual Functions and Multiple Inheritance 458
Virtual functions 458
Behind the scenes 463
Pure virtual functions and abstract base classes 464
Why virtual functions often mean using pointers 464
Virtual destructors 469
Inheritance and move ctor/move = (optional) 471
Antibugging 472
Multiple inheritance 474
Antibugging 476
Chapter 22: Linked Lists 479
What lists are and why have them 479
List< T>
void List< T>
void List< T>
List< T>
-> : a bit of syntactic sugar
More friendly syntax: pointers as conditions 488
The linked list template 489
Antibugging 493
#include < list>
Chapter 23: The Standard Template Library 495
Iterators 495
…with vector, too 499
const and reverse iterators 500
Antibugging 501
Getting really lazy: ranges and auto 502
initializer_lists (optional) 503
algorithm (optional) 505
The erase-remove idiom 506
Antibugging 506
Chapter 24: Building Bigger Projects 509
Namespaces 509
Conditional compilation 510
Libraries 511
g++ 512
Static libraries 512
Shared libraries 512
Linking 512
Running 513
Makefiles 514
Microsoft Visual Studio 514
Static libraries – The easy option 514
Dynamic Link Libraries (DLLs) – the not so easy way 517
Antibugging 523
Chapter 25: History 524
Simula 67 524
Smalltalk 524
What “object-oriented” is 525
C 526
C++ 526
Standards 527
Chapter 26: Esoterica (Recommended) 528
sstream: using strings like cin/cout 528
iomanip: formatted output 531
Command-line arguments 537
Debugging with command-line arguments in Visual Studio 540
Debugging with command-line arguments in Unix 540
static_cast et al 542
Defaulted constructors and = 543
constexpr and static_assert: moving work to compile time 544
User-defined literals: automatic conversion between systems of measurement 548
Lambda functions for one-time use 551
Lambda captures 552
Structured bindings and tuples: returning multiple values at once 557
Smart pointers 561
unique_ptr 561
shared_ptr 567
Antibugging 568
Bit twiddling: & , |, ~, and
Antibugging 574
Chapter 27: Esoterica (Not So Recommended) 575
protected sections, protected inheritance 575
Template specialization 579
friends, and why you shouldn't have any 580
User-defined conversions 585
Chapter 28: C 587
Compiling C 588
I/O 589
printf 589
scanf, and the address-of (& ) operator
fprintf and fscanf fopen and fclose
sprintf and sscanf fputs and fgets
Summary 597
Antibugging 598
Parameter passing with * 598
Antibugging 602
Dynamic memory 602
Chapter 29: Moving On with SDL 604
Writing code 606
Compiling 610
Further resources 611
Appendix A: SDL/SSDL Setup Issues 612
Unix 612
g++ 612
SDL 612
SSDL 613
Making your own Makefiles 613
Antibugging 613
MinGW 614
g++ 614
SDL and SSDL 614
Making your own Makefiles 614
Antibugging 614
Microsoft Visual Studio 615
SDL/SSDL 615
Making your own project files 615
Antibugging 616
Sound 617
Appendix B: Operators 618
Associativity 618
Precedence 618
Overloading 619
Appendix C: ASCII Codes 620
Appendix D: Fundamental Types 622
Appendix E: Escape Sequences 624
Appendix F: Basic C Standard Library 625
cmath 625
cctype 626
cstdlib 627
Appendix G: Common Debugger Commands 628
Microsoft Visual Studio 628
gdb/ddd 629
Appendix H: SSDL Reference 630
Updating the screen 630
Added types 630
Clearing the screen 631
Colors 631
Drawing 631
Images 632
Mouse, keyboard, and events 633
Music 634
Quit messages 635
Sounds 636
Sprites 637
Text 639
Time and synchronization 640
Window 641
References 642
Index 644

Erscheint lt. Verlag 2.10.2019
Zusatzinfo XXVII, 644 p. 187 illus.
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Grafik / Design
Informatik Programmiersprachen / -werkzeuge C / C++
Mathematik / Informatik Informatik Software Entwicklung
Informatik Theorie / Studium Compilerbau
Informatik Weitere Themen Computerspiele
Schlagworte C++ • C++17 • Code • Computer Science • CS • Development • Game • object oriented • OO • programming • Software • source • Textbook
ISBN-10 1-4842-5187-3 / 1484251873
ISBN-13 978-1-4842-5187-4 / 9781484251874
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 13,2 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Torsten T. Will

eBook Download (2024)
Rheinwerk Computing (Verlag)
37,43
Das umfassende Handbuch

von Jürgen Wolf; René Krooß

eBook Download (2023)
Rheinwerk Computing (Verlag)
37,43
C++ lernen – professionell anwenden – Lösungen nutzen

von Ulrich Breymann

eBook Download (2023)
Carl Hanser Verlag GmbH & Co. KG
49,99