Reasons to prefer non-member non-friend functions to member functions:
Cheers and try hosting at Linode.
- Encapsulation: More functions present in a class, lesser is the encapsulation.
- Modularity: Functionality of a class in terms of non-member functions or convenience functions can be defined in different header files in the same namespace. This will enable us to include only required functionality along with the class. For example: Functionality of standard library in namespace std is partitioned into many header files viz. vector, iostream, list etc.
- Extensibility: Writing convenience function as mentioned in above point lets other users extend the functionality. This can be done by defining more code in a new header file with the same namespace.
Cheers and try hosting at Linode.
No comments:
Post a Comment