Zum Hauptinhalt springen Zur Suche springen Zur Hauptnavigation springen

C++20 for Lazy Programmers

62,99 €

Sofort verfügbar, Lieferzeit: Sofort lieferbar

Format auswählen

C++20 for Lazy Programmers, Apress
Quick, Easy, and Fun C++ for Beginners
Von Will Briggs, im heise Shop in digitaler Fassung erhältlich

Produktinformationen "C++20 for Lazy Programmers"

Ready to learn programming with less effort and more fun? Then do it the lazy way! C++20 for Lazy Programmers uses humor and fun to make you actually willing to read and eager to do the projects as you master the popular and powerful C++ language. Along the way it includes many features from the new C++20 standard, such as ranges, spans, format strings, the “spaceship” operator, and concepts (template parameter requirements), and provides brief introductions to modules and coroutines.

With this unique method, you’ll stretch your abilities with a variety of projects, including your own C++ arcade game. You'll construct your own classes, templates, and abstract data types. After reading and using this book you’ll be ready to build real-world C++ applications and game projects on your own.

WHAT YOU WILL LEARN:

* The brand-new C++20 standard
* Programming graphics and games with the SDL library, using SSDL, the "Simple SDL" wrapper library
* How to use the most common C++ compilers -- Visual Studio for Windows, and g++ (with Unix or MinGW) -- and their associated debuggers
* “Anti-bugging” for easy fixes to common problems
* Sound practices for becoming a productive programmer
* How to make your own big projects, including a C++-based arcade game
* The built-in Standard Template Library (STL) functions and classes for easy and efficient programming
* Powerful data types including strings, stacks, vectors, and linked lists -- not by reading about them but by building them -- preparing you further for a career in programming

WHO THIS BOOK IS FOR

All who are new to C++, either self-learners or 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.

Introduction 1-1

1 Getting started 1-9

1.1 A simple program 1-9

1.2 Creating an SSDL project 1-12

1.3 Shapes and the functions that draw them 1-27

1.4 consts and colors 1-35

1.5 Text 1-37

Prominent examples from this chapter: a drawing of a bug's head; a neatly printed poem.

2 Images and sound 2-43

2.1 Images and changing window characteristics 2-43

2.2 Multiple images together 2-48

2.3 Adding transparency with GIMP 2-50

2.4 Sound 2-54

Example: a slide show (Your yard gnome's travel pics).

3 Math: types, operations, consts, and math functions 3-56

3.1 Variables 3-56

3.2 const, constexpr, constinit 3-57

3.3 Math operators 3-59

3.4 Built-in functions and casting 3-62

Examples: diver on a diving board; a 5-pointed star.

C++20 updates: constexpr, constinit.

After this chapter, constexpr/constinit show up in most examples.

4 Mouse, and if 4-67

4.1 Mouse functions 4-67

4.2 if 4-69

4.3 Boolean values and variables 4-73

4.4 A hidden-object game 4-75

Example: The hidden-object game.

5 Loops and text input 5-79

5.1 Keyboard input 5-79

5.2 while and do-while 5-81

5.3 for loops 5-85

5.4 chars and cctype 5-90

5.5 switch 5-94

Examples: the Monty Hall problem; menus.

6 Algorithms and the development process 6-97

6.1 Adventures in robotic cooking 6-97

6.2 Writing a program from start to finish 6-100

Example: a bullseye pattern.

7 Functions 7-106

7.1 Functions that return values 7-106

7.2 Functions that return nothing 7-109

7.3 Global variables and why they're evil 7-111

7.4 How to write a function in four easy steps (and call it in one) 7-1137.5 Why have functions, anyway? 7-117

Example: a multi-frame comic (illustrates code reuse).

8 Functions (Continued) 8-126

8.1 Random numbers 8-126

8.2 Boolean functions 8-131

8.3 Multiple values provided: using & parameters 8-133

8.4 Identifier scope 8-138

8.5 A final note on algorithms 8-140

Examples: various functions using random number generation.

9 Using the debugger 9-141

9.1 A flawed program 9-141

9.2 Breakpoints and watched variables 9-145

9.3 Fixing the stripes 9-145

9.4 Going into functions 9-149

9.4 Fixing the stars 9-149

9.4 Wrap-up 9-150

9.4 Other debugging techniques 9-153

9.4 More on antibugging 9-156

Example: a national flag.

10 Arrays and enum class 10-159

10.1 Arrays 10-159

10.2 Arrays as function parameters 10-160

10.3 enum class 10-166

10.4 Multidimensional arrays 10-166

Examples: monthly temperatures, checkers, tic-tac-toe.

C++20 update: using enum class (which significantly improves the usefulness of enum class).

11 Animation with structs and sprites 11-173

11.1 struct 11-173

11.2 Making a movie with struct and while 11-176

11.3 Sprites 11-182

Examples: bouncing balls; a video aquarium.

C++20 update: designated initializers for structs.

12 Building your own arcade game: input, collisions, and putting it all together 12-188

12.1 Determining input states 12-188

12.2 Events 12-190

12.3 Cooldowns and lifetimes 12-191

12.4 Collisions 12-194

12.5 The big game 12-195

Examples: an arcade game, and the student's own game.

13 Standard I/O and file operations 13-204

13.1 Standard I/O programs in Visual C++ and g++ 13-204

13.2 File I/O (optional) 13-210

Examples: various programs reading/writing text files.

Except for Chapter 21 (virtual functions), this and subsequent chapters use standard console I/O, not the SSDL graphics library.

If used for a course, this chapter likely ends the first semester, so if students are going into a class with a different textbook, they are ready for the console I/O it will certainly require them to know.

14 Character arrays and dynamic memory (pointers) 14-221

14.1 Character arrays 14-221

14.2 Dynamic allocation of arrays. 14-224

14.3 Using the * notation 14-228

Examples: C's string functions, written as examples or offered as exercises; code with new and delete

C++20 updates: array size deduction in new expressions.

15 Classes: the basics 15-232

15.1 Writing classes 15-232

15.2 Constructors 15-235

15.3 const objects, const member functions... 15-239

15.4 ...and const parameters 15-241

15.5 Multiple constructors 15-241

15.6 Default parameters for code reuse 15-244

15.7 Date program (so far) 15-245

Examples: the Date class; the student's own Time class.

16 Classes, continued 16-24816.1 inline functions for efficiency 16-248

16.2 Access functions 16-249

16.3 static members, inline, and constexpr/constinit 16-250

16.4 Separate compilation and include files 16-252

16.5 Multiple-file projects in Microsoft Visual C++ 16-257

16.7 Multiple-file projects in g++ 16-259

16.8 Final Date program 16-264

Examples: the Date class; the student's own Time class, continued.

C++20 updates: constexpr/consteval member functions; constexpr/constinit data members and their interaction with static.

17 Operators, and destructors 17-268

17.1 The basic string class 17-268

17.2 Destructors 17-270

17.3 == and != operators 17-27117.3 Other comparison operators, using the spaceship operator 17-271

17.4 Assignment operators and *this 17-273

17.5 Arithmetic operators 17-275

17.6 [] and () operators 17-279

17.7 >> and

Artikel-Details

Anbieter:
Apress
Autor:
Will Briggs
Artikelnummer:
9781484263068
Veröffentlicht:
11.12.20