网站首页  英汉词典

请输入您要查询的英文单词:

 

单词 Friend function
释义

Friend function

中文百科

友元函数

在面向对象编程中,友谊函数(friend function)是一个指定类别(class)的“朋友”,该函数被允许访问该类别中private、protected、public的数据成员。普通的函数并不能访问这些数据,然而宣告一个函数成为一个类别的友谊函数则被允许访问这些数据。

友谊函数的宣告可以放在类别宣告的任何地方,不受访问限定关键字private、protected、public的限制。一个相似的概念是友谊类别

友谊关键字应该谨慎使用。如果一个拥有private或者protected成员的类别,宣告过多的友谊函数,可能会降低封装性的价值,也可能对整个设计框架产生影响。

英语百科

Friend function 友元函数

In object-oriented programming, a friend function that is a "friend" of a given class is allowed access to private and protected data in that class that it would not normally be able to as if the data was public. Normally, a function that is defined outside of a class cannot access such information. Declaring a function a friend of a class allows this, in languages where the concept is supported.

随便看

 

英汉网英语在线翻译词典收录了3779314条英语词汇在线翻译词条,基本涵盖了全部常用英语词汇的中英文双语翻译及用法,是英语学习的有利工具。

 

Copyright © 2004-2024 encnc.com All Rights Reserved
更新时间:2025/6/17 14:02:10