Effective C++ | 00 Introduction

Effective C++ | 00 Introduction

Effective C++ | 00 Introduction

Book: Effective C++ (Third Edition)

TERMINOLOGY

  • Declaration
    Tells compilers about the name and type of something but omits details

  • Definition
    Provides compilers with the details a declaration omits

  • Initialization
    Process of giving an object its first value

Constructors declared explicit USE!
Prevents them from being used to perform implicit type conversions

Copy constructor
Used to initialize an object with a different object of the same type

Copy assignment Operator
Used to copy the value from one object to another of the same type

Widget w1;                                  // invoke default constructor
Widget w2(w1);                              // invoke copy constructor

w1 = w2;                                    // invoke copy
                                            // assignment operator

If an object is being defined (Widget w3) a (copy) constructor has to be called
It can’t be an assignment

If no new object is being defined (w1 = w2) no constructor, so assignment

Copy constructor defines how an object is passed by value
Pass-by-value means “call the copy constructor”

Function objects
Objects that act like functions

Such objects come from classes that overload operator()
the function call operator

Undefined behavior
Behavior of some constructs in C++ is literally not defined: can’t reliably predict runtime

examples:

// access violation
int* p = 0;
cout << *p;

报错:

在这里插入图片描述

Naming Conventions
lhs: left-hand-side
rhs:right-hand-side

Used as parameter names for functions implementing binary operators

e.g.
operator==
operator*

a * b
operator*(a,b)

Non-member functions
const Rational operator*(const Rational& lhs, const Rational& rhs);

Member functions
lhs represented by the this pointer

Threads
C++ as a language has no notion of threads, concurrency, STL
C++ is concerned, multithreaded programs do NOT exist

TR1: Technical Report1
Specification for new functionality added to C++ standard library
New class and function templates
Hash tables, reference-counting smart pointers, regular expressions
tr1 namespace nested in std namespace

Boost
Offers portable, peer-reviewed, open source C++ libraries
TR1 functionality based on Boost but Boost offers more

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UestcXiye

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值