Static polymorphism
When declaring a function, a programmer can specify for one or much more parameters a default value. Doing so allows the parameters with defaults to optionally be omitted when the function is called, in which case the default arguments will be also used. When a function is called with fewer arguments than there are declared parameters, and explicit arguments are matched to parameters in left-to-right order, and with any unmatched parameters at the end of the parameter list being assigned their default arguments. In many cases, specifying default arguments in an only single function declaration is preferable to providing overloaded function definitions with different numbers of parameters.
Templates in C++programming language provide a sophisticated mechanism for writing generic, polymorphic code. In particular, through the Curiously Recurring Template Pattern, it's possible to implement a form of static polymorphism that closely mimics the syntax for overriding virtual functions. Since C++language templates are type-aware and Turing-complete, they can also be used to let the compiler resolve recursive conditionals and generate substantial programs through template Meta programming. Contrary to some opinion, and template code will not generate a bulk code after compilation with the proper compiler settings
related links: C, C++ Assignment Help
|