O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning C++ Best Practices

Video Description

In this Learning C++ Best Practices training course, expert author Jason Turner will teach you how to write code that is more maintainable, simpler, and faster. This course is designed for users that already have a basic working knowledge of C++.

You will start by learning about expressions and statements, such as variable scopes and initialization. From there, Jason will teach you about resource management, including using raw pointers, managing resources automatically using resources handles and RAII, and using standard containers when interacting with C APIs. Finally, this video tutorial will leave you with a refresher on expressions and statements and resource management, as well as next steps.

Once you have completed this computer based training course, you will have learned how to write simpler, faster, and more maintainable code. Working files are included, allowing you to follow along with the author throughout the lessons.

Table of Contents

  1. Introduction
    1. Introduction 00:04:11
    2. About The Author 00:02:04
    3. Overview Of C++ Best Practices Online Book 00:01:52
    4. Use The Correct Types And Const As Much As Possible 00:03:07
    5. Use The Tools Available 00:06:55
    6. A Note About Optimization 00:05:32
    7. What Are The C++ Core Guidelines 00:02:15
  2. Expressions And Statements
    1. Don't Define A (C-Style) Variadic Function 00:05:57
    2. Prefer A Range-Based For Loop When Possible 00:05:36
    3. Know The Standard Library 00:04:20
    4. Don't Depend On Order Of Evaluation Of Function Arguments 00:04:27
    5. Avoid Casting 00:05:24
    6. Exercise 1 - Chapter 2: Simplify 00:05:19
    7. Exercise 2 - Chapter 2: Use Standard Algorithms 00:04:32
  3. Expressions And Statements - 2
    1. Variable Scopes And Initialization 00:05:28
    2. Properly Initialize Member Variables 00:04:39
    3. Use Lambdas For Complex Initialization, Especially Of Const Variables 00:05:09
    4. Exercise 1 - Chapter 3: Clean Up Object Initialization 00:05:29
    5. Exercise 2 - Chapter 3: Expressions And Statements - Putting It All Together 00:11:17
  4. Resource Management
    1. In Interfaces, Use Raw Pointers To Denote Single Objects Only 00:04:24
    2. Manage Resources Automatically Using Resources Handles And RAII 00:05:07
    3. Avoid Defining Any Default Operations, Or Define Them All 00:04:27
    4. Prefer Stack Objects 00:05:30
    5. Exercise 1 - Chapter 4: Fix Pointer Interface 00:03:06
    6. Exercise 2 - Chapter 4: Implement Scoped Cleanup Object 00:03:50
    7. Exercise 3 - Chapter 4: Consider The Rule Of 0 00:04:33
  5. Resource Management - 2
    1. Don't Use Malloc And Free 00:02:54
    2. Avoid New And Delete 00:04:46
    3. Use unique_ptr Or shared_ptr Correctly 00:05:22
    4. Use std::weak_ptr To Break Cycles 00:03:35
    5. Exercise 1 - Chapter 5: Fix The Memory Error 1 00:04:36
    6. Exercise 2 - Chapter 5: Fix The Memory Error 2 00:05:29
  6. Resource Management - 3
    1. Don't Pass Smart Pointers Unless You Need To Convey Ownership 00:04:00
    2. Avoid Copying Of shared_ptr 00:03:03
    3. Do Not Pass A Pointer Or A Reference Obtained From An Aliased Smart Pointer 00:03:27
    4. Use Standard Containers When Interacting With C APIs 00:04:34
    5. Exercise 1 - Chapter 6: Fix shared_ptr Usage 00:04:16
  7. Conclusion
    1. Expressions And Statements Refresher 00:02:49
    2. Resource Management Refresher 00:03:15
    3. Exercise 1 - Chapter 7: Refactor 00:07:03
    4. Exercise 1 - Chapter 7: Refactor - Solution 00:04:14
    5. Next Steps - Guideline Support Library 00:02:44
    6. Next Steps - Contributing Back 00:02:52
    7. Wrap Up And Thank You 00:01:10