
- OOAD Tutorial
- OOAD - Home
- OOAD - Object Oriented Paradigm
- OOAD - Object Oriented Model
- OOAD - Object Oriented System
- OOAD - Object Oriented Principles
- OOAD - Object Oriented Analysis
- OOAD - Dynamic Modelling
- OOAD - Functional Modelling
- OOAD - UML Analysis Model
- OOAD - UML Basic Notations
- OOAD - UML Structural Diagrams
- OOAD - UML Behavioural Diagrams
- OOAD - Object Oriented Design
- OOAD - Implementation Strategies
- OOAD - Testing & Quality Assurance
- OOAD Useful Resources
- OOAD - Quick Guide
- OOAD - Useful Resources
OOAD Functions Q/A #3
Question:Differentiate between friend function and member functions.
Answer:
Sr. No. | Friend Function | Member Function |
---|---|---|
1 | Friend function is a non-member function that has access to private and protected members of a class. It is not in the scope of the class in which it is declared. | Member function is in scope of the class in which it is declared. |
2 | A friend function cannot be called using object of the class. | A member function is called using object of the class. |
3 | friend keyword is used to declare a function as friend function. | No such keyword is required. |
4 | Class definition using friend function:
class trial { private: { Public: { friend void check ( ); } void check ( ); | Class definition using member function:
class trial { private: { Public: { void check ( ); } trial:: void check ( ); } |
5 | A friend function can be declared as friend in any number of classes. | A member function is a part of any class in which it is declared. |
6 | A friend function can be declared in private, public or protected scope of the class without any effect. | A member function can be declared in private, public or protected scope of the class but have scope accordingly. |
7 | While overloading binary operator, friend function takes two arguments. | While overloading binary operator, member function takes one arguments. |
Advertisements