成员函数的定义与普通函数的定义类似。和任何函数一样,成员函数也包含下面四个部分。
We define member functions similarly to how we define ordinary functions. As with any function, a member function consists of four parts.
对称的操作符,如算术操作符、相等操作符、关系操作符和位操作符,最好定义为普通非成员函数。
Symmetric operators, such as the arithmetic, equality, relational, and bitwise operators, are best defined as ordinary nonmember functions.
具有指针成员且使用默认合成复制构造函数的类具有普通指针的所有缺陷。
Classes that have pointer members and use default synthesized copy control have all the pitfalls of ordinary Pointers.
大多数重载操作符可以定义为普通非成员函数或类的成员函数。
Most overloaded operators may be defined as ordinary nonmember functions or as class member functions.
大多数重载操作符可以定义为普通非成员函数或类的成员函数。
Most overloaded operators may be defined as ordinary nonmember functions or as class member functions.
应用推荐