...希望用户直接和底层数据结构打交道,但是用户又必须访问n这个成员,所以最好的方式便是使用这种访问器函数(accessor function)的形式,提示用户可以通过一个函数(const)来达到访问底层数据的目的。
基于12个网页-相关网页
Flags a property as an accessor function for an element of the default collection.
将属性标记为默认集合的某个元素的访问器函数。
Inlining a very small accessor function will usually decrease code size while inlining a very large function can dramatically increase code size.
内联一个非常小成员访问函数会减少代码,而内联一个非常大的函数代码会戏剧性的增长。
The example above uses the attr() function, which is an accessor and mutator for the attributes of an element.
上面的例子使用了 attr() 函数,这是一个元素中的属性的 accessor 和 mutator。
应用推荐