What is the difference between Function and Member function?

Showing Answers 1 - 4 of 4 Answers

Amar

  • Jul 15th, 2006
 

A function declared/defined within a class is a member function and a function declared/defined outside the scope of a class is a function.

Sachin Bidwai

  • Nov 22nd, 2006
 

I am going to answer this by considering Function as a Normal Function (non member function)

We can access the member function by an object of that class.

Function has not required an object of that class.

we can apply the visiblity levels to the member function.

we cant apply the visiblity levels to the function.

Assuming function is not a part of any class, and member function (obviously) is a part of a class, the difference is their scope.

1. Function - is normally refered to a C-style function which has a global level scope. As long as its declaration is visible in a file where it is being used, and the definition is available somewhere in the application, the linker will find the definition and link to it. It can be used anywhere in the application.

2. Member function - is normally referred to a C++Style method declared/defined inside of a C++ class. The scope for such member functions is the class. They are not accessible outside the class and are only accessible thru an object/instance of such a class. There are, of course, exceptions to this, such as static and friends.

  Was this answer useful?  Yes

KAIRAV

  • Feb 26th, 2018
 

NO BRO!! A member function can be defined outside the class

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions