+ 4

What are the differences between Function and Method? Both in classes and structures?

I encountered a question while challenging where I found this question and I wanna know the diff. b/w each other?

13th Aug 2018, 6:01 PM
Nouman Bin Sami
Nouman Bin Sami - avatar
16 Answers
+ 4
Nom Butt it's same...just a different terminology... if you create void display (); outside class or structure, I mean it's not a part of class or structure , function is called function...once function is a part of class or structure (be it public, private or protected section), same is referred as method or member function... To conclude, there is no difference between function nd method...
13th Aug 2018, 7:18 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 3
Ketan Lalcheta Is member function and function are same?
14th Aug 2018, 12:20 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 3
Ketan Lalcheta Can we use function/member function in structure?
14th Aug 2018, 9:34 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 3
Abdulrahman Algahazi I don't have concepts to any other language except cpp.. So its quite difficult otherwise thanks for your response
14th Aug 2018, 6:23 PM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 3
Ketan Lalcheta this lecture is in c language but I wanna learn this in cpp so if you have this topic in cpp plz send me here
19th Aug 2018, 5:13 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 2
Ketan Lalcheta bro I was just ask that we can create functions in class so just like class we can create function in structure or not? e.g class test { private: int n; public: void show () { // some code } }
14th Aug 2018, 9:57 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 2
Ketan Lalcheta Could you define it briefly?? I mean with example or syntax??
14th Aug 2018, 10:01 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 2
do same as class
14th Aug 2018, 10:35 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Ketan Lalcheta what keyword I used to declare structure function ?
14th Aug 2018, 6:19 PM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 2
ok thanks
15th Aug 2018, 6:16 AM
Nouman Bin Sami
Nouman Bin Sami - avatar
+ 1
function is function... if it is inside class or structure (function is part of class or structure), function is called member function...you can still call it as function.. people just use this nomenclature to differentiate both... not more than that
14th Aug 2018, 5:04 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
function is the only thing we have in c++.. once it is used in class / structure, people call same function as member function
14th Aug 2018, 9:43 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
yes for c++..c++ structure are similar to class and can have function as well.. difference between class nd structure in c++ is default access specifier...
14th Aug 2018, 9:59 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
based on the language community and the name of method and class came from languages un objective language there Technic they call it function to write content function as it in PHP 3.x then when the PHP 4.x released we begin to use OOP and classes way so we start call functions which inside classes 'method' and which r not inside classes we keept it function name that's the difference between method and function as per my experiences go look to python, there nothing to call it method at all, the community call it function in time in the language we call it def its community issue nothing official ;)
14th Aug 2018, 12:42 PM
Abdulrahman Algahazi
+ 1
struct
14th Aug 2018, 6:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Nom Butt go through below link and also study next lecture: https://www.sololearn.com/learn/2917/?ref=app
14th Aug 2018, 6:34 PM
Ketan Lalcheta
Ketan Lalcheta - avatar