Requirement:
Suppose a company “ABC”
is conducting a test to hire you as OOP Developer and asked you develop a
calculator for the basic Arithmetic operators (+, -, *, /, %), where you have
to deal at least 11-digit numbers. The numbers can be of with decimal point or
without decimal point. The company wants you to develop an efficient code. You
can choose any of the following options to develop this whole scenario:
- Function
Overloading
-
Class
Template
You
have to answer, which option will you choose and arguments in favor of your
chosen option regarding code efficiency, code complexity and other factors.
My personal preference for developing a calculator are to
develop it victimization the conception of operate overloading as a (URL: raiseforsuccess.blogspot.com) result of I
feel that templates area unit helpful after we aren't awake to the information
form of the information.
Function overlapping is that the method of victimization a
similar name for 2 or a lot of functions. the key to overlapping is that every
definition of the operate should use either differing types of parameters or a
unique variety of parameters. it's solely through these variations the compiler
is aware of that operate to decision within the given (URL: raiseforsuccess.blogspot.com) scenario. The conception
functions of overlapping are additionally called Polymorphism. operate
overloading is employed among the category conception or constructors and
member functions.
Pros:
- Program becomes simple to know
- Easy to maintainability of the code
- Function overlapping brings flexibility in C++ programs
- This is used once multiple functions do similar operations
- Function overlapping will take varied numbers or arguments
Click Here