Skip to content

Operators

operator overloading

当运算符 overload as member funcitons 时, 左侧的操作数应是调用对象;当overload as non-member funcitons 时,运算符左侧的操作数对应于运算符函数的第一个参数,运算符表达式右侧的操作数对应于运算符函数的第二个参数。
友元函数是在类声明中声明的,但它不是成员函数,因此不能使用成员运算符来调用。 20240708161630 how does C++ know how to apply operators to user-defined classes?
20240707151410 20240707151443

const object can only call const functions
return type with const -> can't be assigned(changed) as lvalue
for a const variable you have to do them(declare, initialize) simutaneously 截屏2024-07-09 17.59.22 20240709182028 20240709182851 20240709183147

canonical forms

20240708165205 20240708165619

20240708180210 20240708180237 20240708180255 20240708225446 20240708225548

POLA(principle of least astonishment

20240709004752 20240709004814 20240709010159