what are differences between function and method?
what are differences between function and method?
There is no difference. The distinction is that a method
is attached to a class and a function is a stand alone part of code. Since it is an OO language, you can't have
functions, which stand alone (outside of classes).
method: it returns a value.
ex: int add(int a,int b)
{ return a*b;}
function: it doesn't return value
ex: void add(int a,int b)
{ printf("%d%d" a,b); }