---
title: "Difference between a method and a function"  
description: "Difference between a method and a function"  
author: "John Smith"  
published: 2015-07-20  
updated: 2015-07-20  
canonical: https://www.mindstick.com/forum/23354/difference-between-a-method-and-a-function  
category: "oops"  
tags: ["oops"]  
reading_time: 2 minutes  

---

# Difference between a method and a function

Hi Everyone,\
What is the [difference between method](https://www.mindstick.com/interview/2444/difference-between-method-and-selector) and [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)?\
Can someone provide a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) [explanation](https://yourviews.mindstick.com/view/84608/what-are-hindenburg-s-allegations-against-adani-detailed-explanation) of [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) and [functions](https://www.mindstick.com/forum/160140/explain-the-role-of-functions-as-a-service-faas-in-serverless-computing)?\
\
Good for the beginners.\
\
Thanks,\
John

## Replies

### Reply by Shivani

In Simple Words

**Function** — a set of instructions that perform a task

- Functions have an independent existence. You can define them outside of the class.
- Functions are self-describing pieces of code.

**Method** — a set of instructions that are associated with an object.

- Methods do not have an independent existence. They are always defined within a class, struct, or enum.
- Methods are used to manipulate the instance variables of a class.

\

### Reply by Anonymous User

A function is a piece of code that is called by name. It can be passed data to operate on (ie. the parameters) and can optionally return data (the return value).\
All data that is passed to a function is explicitly passed.\
A [method](https://www.mindstick.com/forum/166/webservice-method) is a piece of code that is called by name that is associated with an object. In most respects it is identical to a function except for two key differences.\
It is implicitly passed for the object for which it was called.It is able to operate on data that is contained within the class (remembering that an object is an instance of a class - the class is the definition, the object is an instance of that data).


---

Original Source: https://www.mindstick.com/forum/23354/difference-between-a-method-and-a-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
