Member Functions vs. Global Functions (Also Called Free Functions)

The printUniversal and printStandard member functions take no arguments, because these member functions implicitly know that they’re to print the data members of the particular Time object on which they’re invoked. This can make member function calls more concise than conventional function calls in procedural programming.


Image Software Engineering Observation 9.3

Using an object-oriented programming approach often simplifies function calls by reducing the number of parameters. This benefit derives from the fact that encapsulating data members and member functions within a class gives the member functions the right to access the data members.



Image Software Engineering Observation 9.4

Member functions are usually shorter than functions in non-object-oriented programs, because the data stored in data members have ideally been validated by a constructor or by member functions that store new data. Because the data is already in the object, the member-function calls often have no arguments or fewer arguments than function calls in non-object-oriented languages. Thus, the calls, the function definitions and the function prototypes are shorter. This improves many aspects of program development.



Image Error-Prevention Tip 9.3

The fact that member function calls generally take either no arguments or substantially fewer arguments than conventional function calls in non-object-oriented languages reduces the likelihood of passing the wrong arguments, the wrong types of arguments or the wrong number of arguments.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.241.64