+ 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?
16 Respostas
+ 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...
+ 3
Ketan Lalcheta Is member function and function are same?
+ 3
Ketan Lalcheta Can we use function/member function in structure?
+ 3
Abdulrahman Algahazi I don't have concepts to any other language except cpp.. So its quite difficult otherwise thanks for your response
+ 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
+ 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
}
}
+ 2
Ketan Lalcheta Could you define it briefly?? I mean with example or syntax??
+ 2
do same as class
+ 2
Ketan Lalcheta what keyword I used to declare structure function ?
+ 2
ok thanks
+ 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
+ 1
function is the only thing we have in c++.. once it is used in class / structure, people call same function as member function
+ 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...
+ 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 ;)
+ 1
struct
+ 1
Nom Butt go through below link and also study next lecture:
https://www.sololearn.com/learn/2917/?ref=app