在C ++中,方法和函数之间的区别是什么 [英] In C++, what is the difference between a method and a function

查看:264
本文介绍了在C ++中,方法和函数之间的区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

>方法和函数之间的区别

Possible Duplicate:
What is the difference between a method and a function

我想让我的术语正确。

方法和函数之间有什么区别,对于C ++特别。

What is the difference between a method and a function, in regards to C++ specifically.

这是一个方法不返回任何东西,只是对其类进行操作;而函数有一个返回值?

Is it that a method returns nothing and just preforms operations on its class; while a function has a return value?

推荐答案

就C ++标准而言,方法。

As far as the C++ standard is concerned, there is no such thing as a "method". This terminology is used in other OO languages (e.g. Java) to refer to member functions of a class.

在常见的用法中,你会发现大多数人会使用方法和函数或多或少可互换,尽管有些人会限制对方法函数使用方法(相对于不是类成员的自由函数)。

In common usage, you'll find that most people will use "method" and "function" more or less interchangeably, although some people will restrict use of "method" to member functions (as opposed to "free functions" which aren't members of a class).

这篇关于在C ++中,方法和函数之间的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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