• Animal
  • Auto
  • Computers
  • Education
  • Finance
  • Health
  • Math
  • Mobiles
  • Programming
  • Science
  • Sports
  • Technology
  • Terms
  • Web

  • Difference Between Function and Method

    Function vs Method

    When people talk about function and method terms are used synonymously in computer science or programming languages. Both are independent unit of code which can be called.

    Below are the Differences Between Function and Method


    • A method does not have independent existence and has to be defined with in a class.Example:A insert() method in vector STL in c++.
    • A method is defined in a class,so methods are applicable only in OOP languages.
    • Methods are called by class objects i.e reference variables.
      Methods have access specifiers.
    • The calling objects data is implicitly passed.


    • A function has independent existence and can be defined anywhere in a program.Example: All functions in C language like main(),atoi() etc.
    • Functions can be used in both OOP languages and procedural languages.
    • Functions are not called by objects,they are called independently.
    • Functions do not have access specifiers.
    • All data has to be explicitly passed.

    Posted under: Programming
    1957 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below:

    Leave a Reply

    page counter
    NiharsWorld on Twitter NiharsWorld on Facebook NiharsWorld RSS Feed