Рет қаралды 1,263
In this video we talk about functions. How they help us split out the functionality of our code and maintain its readability and our sanity. Here we only touch up on the basics of function writing, but we cover most of the best practices related to it. Enjoy!
🎓 Slides: github.com/cpp-for-yourself/s...
Related materials
- Fibonacci numbers: en.wikipedia.org/wiki/Fibonac...
- Video where we talk about warnings: • Common compilation fla...
- Video on control structure: • Control structures in C++
- Video on vectors: • STL sequence container...
- Setting up your terminal and text editor: • Setting up terminal an...
Please support my free work 😉🙏
- Through Patreon: / code_for_yourself
- Through GitHub Sponsors: github.com/sponsors/niosus
Get a FREE Audible trial here
- US: www.audibletrial.com/CodeForY...
- DE: www.amazon.de/hz/audible/mlp?...
Stuff I'm using to prepare this course
- Keyboard: Logitech MX Keys: amzn.to/3SbOhg8
- Mouse: Logitech MX Vertical: amzn.to/3qVYYI4
- Monitor: Dell P2720DC: amzn.to/3Bthv3A
- Camera: Sony a6400: amzn.to/3duP39x
- Microphone: Rode Wireless GO II: amzn.to/3QUH2sc
- SD card: SanDisk Extreme PRO 128GB: amzn.to/3BRCnS5
Contents
00:00 Intro
00:53 Function to organize code
03:00 Some technical details on functions
04:20 How to write good functions
06:53 Use [[nodiscard]] attribute!
08:31 Good function example
10:28 Bad function example
11:53 Declaration and definitions of functions
13:14 Passing big objects to functions
15:36 Problem with passing by reference
16:30 Use const references!
18:21 Never return a local reference!
19:34 Function overloading
21:12 Default function arguments
23:10 Outro