This chapter covers some guidelines and best practices when working with modern C++. The guidelines include discussion on 1) the auto keyword and type deduction,2) how to think about memory ownership and how to use smart pointers (covering both unique pointers and shared pointers), 3) different mechanisms for handling functions, and 4) how to organize code into header files (.hpp or .h extension) and implementation files (.cpp extension). After reading this chapter, one should feel more confident in developing safer and more transparent C++ code.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Modern C++ and Guidelines

  • Raymond J. Spiteri,
  • Kyle Klenk

摘要

This chapter covers some guidelines and best practices when working with modern C++. The guidelines include discussion on 1) the auto keyword and type deduction,2) how to think about memory ownership and how to use smart pointers (covering both unique pointers and shared pointers), 3) different mechanisms for handling functions, and 4) how to organize code into header files (.hpp or .h extension) and implementation files (.cpp extension). After reading this chapter, one should feel more confident in developing safer and more transparent C++ code.