Answers for "difference between function and method"

C++
3

Difference between Methods and Functions in JavaScript

Function — a set of instructions that perform a task. We can define a 
function using the function keyword, followed by Name and optional parameters. 
Body of function is enclosed in Curly braces.


Method — a set of instructions that are associated with an object. 
A JavaScript method is a property of an object that contains a function 
definition. Methods are functions stored as object properties.
Object method can be accessed with the following syntax:
object = {
    methodName: function() {
        // Content
    }
};

object.methodName()
Posted by: Guest on May-23-2021
4

difference between function and method

#inclue<iostream>
using namespace std; // Bad Practice!!!

/* 
	*******IF YOU DONT KNOW OOP(OBJECT ORIENTED PROGRAMMING) FIRST LEARN IT THEN COME HERE
	AGAIN*******

	Simply, Method = Function.

	But Difference is that

	We call a Function A 'Method' When That Function Is Written Inside a Class(a blueprint)
	But if that Function is not Declared inside a class body then we call it 'Function'
*/

//Example:

class Employee
{
  public:
  	void getData(void); // This Is A 'METHOD'
}

void Employee :: getData(void) // This is Also A Method Because It Is Pointing Towards The GetData Function In Employee Class.
{
  cout<<"GET DATA!!!!!!"<<std::endl; // Good Practice (std::endl) use "std::"
}

int main() // This Is A Function, Cause It's Not Pointing Towards The Class As Well As Not Initialized Inside The Class Body
{
  
  cout<<"Hello"<<endl;
  
  return 0;
}

void DoSomethingGood(void) // This Is A Function As Well.
{
  
  if (2+2==5)
    return;
}
Posted by: Guest on July-21-2021
5

what is method in python

It's a function which is a member of a class:
Posted by: Guest on June-23-2020
0

method function difference

A method, like a function, is a set of instructions that perform a task. The difference is that a method is associated with an object, while a function is not.
Posted by: Guest on July-01-2021

Code answers related to "difference between function and method"

Browse Popular Code Answers by Language