In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is mainly about "what's the difference between method and function". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what's the difference between method and function?"
A function is a piece of code that is called by name. It can pass some data (parameters) in for processing, and then return some data (return value), or no return value.
All data passed to the function is passed explicitly.
A method is also a piece of code that is also called by name, but it is associated with an object. Methods and functions are roughly the same, but there are two main differences:
Data in the method is passed implicitly
Method can manipulate data within a class (remember, an object is an instantiation of a class-the class defines a data type, and an object is an instantiation of that data type)
The above is only a brief explanation, ignoring issues such as scope.
For 1), you should add "methods are called member functions in C++". Therefore, the difference between "method" and "function" in C++ is the difference between "member function" and "function". In addition, programming languages such as Java have only "methods". So this is the direct difference between "static method" and "method".
For 2), you should add that the method can manipulate private instance (member) data that has been declared in the class. Other code can access public instance data.
Methods are related to objects
The function is independent of the object.
There are only methods in Java, only functions in C, and C++ depends on whether you are in the class or not.
At this point, I believe you have a deeper understanding of "what's the difference between method and function". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.