Effective C++

GitHub – taeguk/Effective-Cpp-Series: My example and experimental source codes about books of Effective C++ Series, “Effective C++ 3/E” and “Effective Modern C++” by Scott Meyers.

C++ Basic

C++ Union

Using constenuminline instead of #define

Using const whenever possible

Make sure init before use

Constructor,Destructor, Assignment op

Silent functions in class

Explicitly delete silent functions

Virtual destructors in polymorphic

Nonthrow destructors

No virtual call in construction and destruction

Operator= return *this

Operator= handle self-assignment

Deep copy when copy

Resource Management

Using resource-managing class

Copying resource-managing class

Access raw in resource-managing class

Same form in new and delete

Standalone statement when smart pointers

Design

Make interface to easy use

Design class as type

Pass by const reference instead of value

Dont return reference

Make data member private

Non-member instead of member function

Non-member function when type conversion

Non-throw swap

Implementation

Postpone variable definitions

Consider casting

Avoid return handles of object internals

Strive for exception safe

Inlining

Compilation dependency

Inheritance and OOP

Public inheritance means is-a

Avoid hiding base class through overwrite

Interface extend and implementation extend

Alternative virtual

Never redefine non-virtual from base class

Never redefine default parameters

Composition means has-a or implement-of

Private inheritance means implement-of

  • when implement-of is using protected member, consider private inheritance

Multiple inheritance

Template & Generic Programming

Implicit interface and compile-time polymoriphism

Using typename

  • using typename means it is a type not others
    • typename Class::Type_t

Templatized base class

Template Parameter

Member function template

Non-member function to cast

  • member function can not conversion the caller’s type, while non-member function can

Traits class

Meta programming

New & Delete

Miscellany

原文地址:https://blog.csdn.net/qq_39384184/article/details/134754354

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_31144.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注