C ++将类成员变量称为“属性"是否正确? [英] C++ Is it correct to call class member variables "attributes"?

查看:109
本文介绍了C ++将类成员变量称为“属性"是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以消除C ++的类属性和方法的歧义吗?我的印象是属性意味着任何成员变量,方法意味着任何成员函数.

Can someone please disambiguate class attributes and methods for C++? I was under the impression that attribute means any member variable, and method means any member function.

谢谢

推荐答案

定义正确".

通常将数据成员和成员函数分别称为属性/属性"和方法"-这是通用的OO措辞. (不过,C ++中的属性"用于其他内容,因此,这很可能是来源的困惑.)

Referring to data members and member functions as "attributes/properties" and "methods", respectively, is common practice - it's the general OO wording. ("attributes" are used in C++ for something else, though, so this may very well be a source of confusion.)

但是,C ++标准没有使用这些术语(当然,除了属性,如上所述).如果您不想冒任何风险并且始终正确无误,请使用数据成员"和成员函数".

The C++ standard, however, does not use these terms (apart from attributes of course, as explained above). If you don't want to risk anything and always be correct, use "data members" and "member functions".

但是,如果您只想向Java程序员解释C ++,则一开始可能会忽略属性"和方法".

But if you only want to explain C++ to a Java programmer, you may get away with "property" and "method" in the beginning.

这篇关于C ++将类成员变量称为“属性"是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆