c - method vs function vs procedure vs class? -


I know the basics of these methods, procedures, functions and classes but I always want to differentiate between people oriented I can confuse programming, so can anyone tell me the difference between those simple examples?

A class , currently, traditional OOP is a collection of data (Member variables) that work on data (member work or methods) are bound together with those functions / processes.

The other three words ... well, it depends on whether the class has no relation with the other three words that it is different from "included" (more precisely "related") .

A function is a collection of computing statements. So there is a process in some very anal-compliant languages, however, a function returns a value and there is no process. Processes of such languages ​​are usually used for their side effects (such as I / O), whereas the functions are used for calculations and side effects are used to avoid.

Most languages ​​are not that anal retainer, and as a result people will use the term "function" and "function", "for each other, they prefer each other on the basis of their background. For, C / C ++ / Java / which is used to "function", while module- * programmers use "process.")

A Method A function bound to a class (or w Process), in fact, all OOP languages ​​do not use the word "method" in a typical (but universal!) Implementation, the first parameter (which is this Or like the self / code> or the like) is not said, as I said, universal. Some languages ​​clarified the first parameter (and thus allow you to be nominated whatever you wish ), While Any other magic does not have any first parameter.


Edit to add this example Pre> class MyClass {int subscribeable; Zero setmemberable processor (int v) {subscriber variable = v; } Int getMemberVariableFunction () {return subscriber convertible; }}; Zero white processing {cout & lt; & Lt; Luggage; } Int plain old function (int stuff) {returns 2 * accessories; }

This code has both getMemberVariableProcedure and getMemberVariableFunction both methods.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -