0
What is the need for defining a method of a class, outside the class definition using the scope resolution operator?
When it is possible to define a method of class within the class definition, I wonder why would we define a method outside of a class? What situations create a need for that? Example : class add { int a,b; public: add() { a='\0'; b='\0'; } void display(); }; void add::display() { int sum; sum = a+b; cout<<sum; } Why would we define the method display() outside the definition of the class "add"?
1 Answer
+ 11
Separating the interface and implementation of the class' methods in real-world software engineering is a must for having a well-organized and safe system.
[https://accu.org/index.php/journals/269]
[http://www.cppforschool.com/tutorial/separate-header-and-implementation-files.html]